| OLD | NEW |
| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "media/base/audio_decoder_config.h" | 8 #include "media/base/audio_decoder_config.h" |
| 9 #include "media/base/decoder_buffer.h" | 9 #include "media/base/decoder_buffer.h" |
| 10 #include "media/base/video_decoder_config.h" | 10 #include "media/base/video_decoder_config.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 interfaces::AudioDecoderConfig::From(stream_->audio_decoder_config()); | 85 interfaces::AudioDecoderConfig::From(stream_->audio_decoder_config()); |
| 86 } else if (stream_->type() == media::DemuxerStream::VIDEO) { | 86 } else if (stream_->type() == media::DemuxerStream::VIDEO) { |
| 87 video_config = | 87 video_config = |
| 88 interfaces::VideoDecoderConfig::From(stream_->video_decoder_config()); | 88 interfaces::VideoDecoderConfig::From(stream_->video_decoder_config()); |
| 89 } else { | 89 } else { |
| 90 NOTREACHED() << "Unsupported config change encountered for type: " | 90 NOTREACHED() << "Unsupported config change encountered for type: " |
| 91 << stream_->type(); | 91 << stream_->type(); |
| 92 } | 92 } |
| 93 | 93 |
| 94 callback.Run(interfaces::DemuxerStream::STATUS_CONFIG_CHANGED, | 94 callback.Run(interfaces::DemuxerStream::STATUS_CONFIG_CHANGED, |
| 95 interfaces::MediaDecoderBufferPtr(), audio_config.Pass(), | 95 interfaces::DecoderBufferPtr(), audio_config.Pass(), |
| 96 video_config.Pass()); | 96 video_config.Pass()); |
| 97 return; | 97 return; |
| 98 } | 98 } |
| 99 | 99 |
| 100 if (status == media::DemuxerStream::kAborted) { | 100 if (status == media::DemuxerStream::kAborted) { |
| 101 callback.Run(interfaces::DemuxerStream::STATUS_ABORTED, | 101 callback.Run(interfaces::DemuxerStream::STATUS_ABORTED, |
| 102 interfaces::MediaDecoderBufferPtr(), audio_config.Pass(), | 102 interfaces::DecoderBufferPtr(), audio_config.Pass(), |
| 103 video_config.Pass()); | 103 video_config.Pass()); |
| 104 return; | 104 return; |
| 105 } | 105 } |
| 106 | 106 |
| 107 DCHECK_EQ(status, media::DemuxerStream::kOk); | 107 DCHECK_EQ(status, media::DemuxerStream::kOk); |
| 108 if (!buffer->end_of_stream()) { | 108 if (!buffer->end_of_stream()) { |
| 109 DCHECK_GT(buffer->data_size(), 0); | 109 DCHECK_GT(buffer->data_size(), 0); |
| 110 // Serialize the data section of the DecoderBuffer into our pipe. | 110 // Serialize the data section of the DecoderBuffer into our pipe. |
| 111 uint32_t num_bytes = buffer->data_size(); | 111 uint32_t num_bytes = buffer->data_size(); |
| 112 CHECK_EQ(WriteDataRaw(stream_pipe_.get(), buffer->data(), &num_bytes, | 112 CHECK_EQ(WriteDataRaw(stream_pipe_.get(), buffer->data(), &num_bytes, |
| 113 MOJO_READ_DATA_FLAG_ALL_OR_NONE), | 113 MOJO_READ_DATA_FLAG_ALL_OR_NONE), |
| 114 MOJO_RESULT_OK); | 114 MOJO_RESULT_OK); |
| 115 CHECK_EQ(num_bytes, static_cast<uint32_t>(buffer->data_size())); | 115 CHECK_EQ(num_bytes, static_cast<uint32_t>(buffer->data_size())); |
| 116 } | 116 } |
| 117 | 117 |
| 118 // TODO(dalecurtis): Once we can write framed data to the DataPipe, fill via | 118 // TODO(dalecurtis): Once we can write framed data to the DataPipe, fill via |
| 119 // the producer handle and then read more to keep the pipe full. Waiting for | 119 // the producer handle and then read more to keep the pipe full. Waiting for |
| 120 // space can be accomplished using an AsyncWaiter. | 120 // space can be accomplished using an AsyncWaiter. |
| 121 callback.Run(static_cast<interfaces::DemuxerStream::Status>(status), | 121 callback.Run(static_cast<interfaces::DemuxerStream::Status>(status), |
| 122 interfaces::MediaDecoderBuffer::From(buffer), | 122 interfaces::DecoderBuffer::From(buffer), audio_config.Pass(), |
| 123 audio_config.Pass(), video_config.Pass()); | 123 video_config.Pass()); |
| 124 } | 124 } |
| 125 | 125 |
| 126 } // namespace media | 126 } // namespace media |
| OLD | NEW |