Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(357)

Side by Side Diff: media/mojo/services/mojo_demuxer_stream_impl.cc

Issue 1977173002: Rename media::interfaces to media::mojom. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: android + chromeos files Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/mojo/services/mojo_demuxer_stream_impl.h" 5 #include "media/mojo/services/mojo_demuxer_stream_impl.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/numerics/safe_conversions.h" 11 #include "base/numerics/safe_conversions.h"
12 #include "media/base/audio_decoder_config.h" 12 #include "media/base/audio_decoder_config.h"
13 #include "media/base/decoder_buffer.h" 13 #include "media/base/decoder_buffer.h"
14 #include "media/base/video_decoder_config.h" 14 #include "media/base/video_decoder_config.h"
15 #include "media/mojo/common/media_type_converters.h" 15 #include "media/mojo/common/media_type_converters.h"
16 #include "mojo/public/cpp/system/data_pipe.h" 16 #include "mojo/public/cpp/system/data_pipe.h"
17 17
18 namespace media { 18 namespace media {
19 19
20 MojoDemuxerStreamImpl::MojoDemuxerStreamImpl( 20 MojoDemuxerStreamImpl::MojoDemuxerStreamImpl(
21 media::DemuxerStream* stream, 21 media::DemuxerStream* stream,
22 mojo::InterfaceRequest<interfaces::DemuxerStream> request) 22 mojo::InterfaceRequest<mojom::DemuxerStream> request)
23 : binding_(this, std::move(request)), 23 : binding_(this, std::move(request)),
24 stream_(stream), 24 stream_(stream),
25 weak_factory_(this) {} 25 weak_factory_(this) {}
26 26
27 MojoDemuxerStreamImpl::~MojoDemuxerStreamImpl() { 27 MojoDemuxerStreamImpl::~MojoDemuxerStreamImpl() {
28 } 28 }
29 29
30 // This is called when our DemuxerStreamClient has connected itself and is 30 // This is called when our DemuxerStreamClient has connected itself and is
31 // ready to receive messages. Send an initial config and notify it that 31 // ready to receive messages. Send an initial config and notify it that
32 // we are now ready for business. 32 // we are now ready for business.
(...skipping 12 matching lines...) Expand all
45 options.capacity_num_bytes = 1.5 * (1024 * 1024); 45 options.capacity_num_bytes = 1.5 * (1024 * 1024);
46 } else { 46 } else {
47 // Other types don't require a lot of room, so use a smaller pipe. 47 // Other types don't require a lot of room, so use a smaller pipe.
48 options.capacity_num_bytes = 512 * 1024; 48 options.capacity_num_bytes = 512 * 1024;
49 } 49 }
50 50
51 mojo::DataPipe data_pipe(options); 51 mojo::DataPipe data_pipe(options);
52 stream_pipe_ = std::move(data_pipe.producer_handle); 52 stream_pipe_ = std::move(data_pipe.producer_handle);
53 53
54 // Prepare the initial config. 54 // Prepare the initial config.
55 interfaces::AudioDecoderConfigPtr audio_config; 55 mojom::AudioDecoderConfigPtr audio_config;
56 interfaces::VideoDecoderConfigPtr video_config; 56 mojom::VideoDecoderConfigPtr video_config;
57 if (stream_->type() == media::DemuxerStream::AUDIO) { 57 if (stream_->type() == media::DemuxerStream::AUDIO) {
58 audio_config = 58 audio_config =
59 interfaces::AudioDecoderConfig::From(stream_->audio_decoder_config()); 59 mojom::AudioDecoderConfig::From(stream_->audio_decoder_config());
60 } else if (stream_->type() == media::DemuxerStream::VIDEO) { 60 } else if (stream_->type() == media::DemuxerStream::VIDEO) {
61 video_config = 61 video_config =
62 interfaces::VideoDecoderConfig::From(stream_->video_decoder_config()); 62 mojom::VideoDecoderConfig::From(stream_->video_decoder_config());
63 } else { 63 } else {
64 NOTREACHED() << "Unsupported stream type: " << stream_->type(); 64 NOTREACHED() << "Unsupported stream type: " << stream_->type();
65 return; 65 return;
66 } 66 }
67 67
68 callback.Run(static_cast<interfaces::DemuxerStream::Type>(stream_->type()), 68 callback.Run(static_cast<mojom::DemuxerStream::Type>(stream_->type()),
69 std::move(data_pipe.consumer_handle), std::move(audio_config), 69 std::move(data_pipe.consumer_handle), std::move(audio_config),
70 std::move(video_config)); 70 std::move(video_config));
71 } 71 }
72 72
73 void MojoDemuxerStreamImpl::Read(const ReadCallback& callback) { 73 void MojoDemuxerStreamImpl::Read(const ReadCallback& callback) {
74 stream_->Read(base::Bind(&MojoDemuxerStreamImpl::OnBufferReady, 74 stream_->Read(base::Bind(&MojoDemuxerStreamImpl::OnBufferReady,
75 weak_factory_.GetWeakPtr(), callback)); 75 weak_factory_.GetWeakPtr(), callback));
76 } 76 }
77 77
78 void MojoDemuxerStreamImpl::EnableBitstreamConverter() { 78 void MojoDemuxerStreamImpl::EnableBitstreamConverter() {
79 stream_->EnableBitstreamConverter(); 79 stream_->EnableBitstreamConverter();
80 } 80 }
81 81
82 void MojoDemuxerStreamImpl::OnBufferReady( 82 void MojoDemuxerStreamImpl::OnBufferReady(
83 const ReadCallback& callback, 83 const ReadCallback& callback,
84 media::DemuxerStream::Status status, 84 media::DemuxerStream::Status status,
85 const scoped_refptr<media::DecoderBuffer>& buffer) { 85 const scoped_refptr<media::DecoderBuffer>& buffer) {
86 interfaces::AudioDecoderConfigPtr audio_config; 86 mojom::AudioDecoderConfigPtr audio_config;
87 interfaces::VideoDecoderConfigPtr video_config; 87 mojom::VideoDecoderConfigPtr video_config;
88 88
89 if (status == media::DemuxerStream::kConfigChanged) { 89 if (status == media::DemuxerStream::kConfigChanged) {
90 DVLOG(2) << __FUNCTION__ << ": ConfigChange!"; 90 DVLOG(2) << __FUNCTION__ << ": ConfigChange!";
91 // Send the config change so our client can read it once it parses the 91 // Send the config change so our client can read it once it parses the
92 // Status obtained via Run() below. 92 // Status obtained via Run() below.
93 if (stream_->type() == media::DemuxerStream::AUDIO) { 93 if (stream_->type() == media::DemuxerStream::AUDIO) {
94 audio_config = 94 audio_config =
95 interfaces::AudioDecoderConfig::From(stream_->audio_decoder_config()); 95 mojom::AudioDecoderConfig::From(stream_->audio_decoder_config());
96 } else if (stream_->type() == media::DemuxerStream::VIDEO) { 96 } else if (stream_->type() == media::DemuxerStream::VIDEO) {
97 video_config = 97 video_config =
98 interfaces::VideoDecoderConfig::From(stream_->video_decoder_config()); 98 mojom::VideoDecoderConfig::From(stream_->video_decoder_config());
99 } else { 99 } else {
100 NOTREACHED() << "Unsupported config change encountered for type: " 100 NOTREACHED() << "Unsupported config change encountered for type: "
101 << stream_->type(); 101 << stream_->type();
102 } 102 }
103 103
104 callback.Run(interfaces::DemuxerStream::Status::CONFIG_CHANGED, 104 callback.Run(mojom::DemuxerStream::Status::CONFIG_CHANGED,
105 interfaces::DecoderBufferPtr(), std::move(audio_config), 105 mojom::DecoderBufferPtr(), std::move(audio_config),
106 std::move(video_config)); 106 std::move(video_config));
107 return; 107 return;
108 } 108 }
109 109
110 if (status == media::DemuxerStream::kAborted) { 110 if (status == media::DemuxerStream::kAborted) {
111 callback.Run(interfaces::DemuxerStream::Status::ABORTED, 111 callback.Run(mojom::DemuxerStream::Status::ABORTED,
112 interfaces::DecoderBufferPtr(), std::move(audio_config), 112 mojom::DecoderBufferPtr(), std::move(audio_config),
113 std::move(video_config)); 113 std::move(video_config));
114 return; 114 return;
115 } 115 }
116 116
117 DCHECK_EQ(status, media::DemuxerStream::kOk); 117 DCHECK_EQ(status, media::DemuxerStream::kOk);
118 if (!buffer->end_of_stream()) { 118 if (!buffer->end_of_stream()) {
119 DCHECK_GT(buffer->data_size(), 0u); 119 DCHECK_GT(buffer->data_size(), 0u);
120 // Serialize the data section of the DecoderBuffer into our pipe. 120 // Serialize the data section of the DecoderBuffer into our pipe.
121 uint32_t bytes_to_write = base::checked_cast<uint32_t>(buffer->data_size()); 121 uint32_t bytes_to_write = base::checked_cast<uint32_t>(buffer->data_size());
122 uint32_t bytes_written = bytes_to_write; 122 uint32_t bytes_written = bytes_to_write;
123 CHECK_EQ(WriteDataRaw(stream_pipe_.get(), buffer->data(), &bytes_written, 123 CHECK_EQ(WriteDataRaw(stream_pipe_.get(), buffer->data(), &bytes_written,
124 MOJO_READ_DATA_FLAG_ALL_OR_NONE), 124 MOJO_READ_DATA_FLAG_ALL_OR_NONE),
125 MOJO_RESULT_OK); 125 MOJO_RESULT_OK);
126 CHECK_EQ(bytes_to_write, bytes_written); 126 CHECK_EQ(bytes_to_write, bytes_written);
127 } 127 }
128 128
129 // TODO(dalecurtis): Once we can write framed data to the DataPipe, fill via 129 // TODO(dalecurtis): Once we can write framed data to the DataPipe, fill via
130 // the producer handle and then read more to keep the pipe full. Waiting for 130 // the producer handle and then read more to keep the pipe full. Waiting for
131 // space can be accomplished using an AsyncWaiter. 131 // space can be accomplished using an AsyncWaiter.
132 callback.Run(static_cast<interfaces::DemuxerStream::Status>(status), 132 callback.Run(static_cast<mojom::DemuxerStream::Status>(status),
133 interfaces::DecoderBuffer::From(buffer), std::move(audio_config), 133 mojom::DecoderBuffer::From(buffer), std::move(audio_config),
134 std::move(video_config)); 134 std::move(video_config));
135 } 135 }
136 136
137 } // namespace media 137 } // namespace media
OLDNEW
« no previous file with comments | « media/mojo/services/mojo_demuxer_stream_impl.h ('k') | media/mojo/services/mojo_media_application.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698