OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/filters/chunk_demuxer.h" | 5 #include "media/filters/chunk_demuxer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <deque> | 8 #include <deque> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 }; | 219 }; |
220 | 220 |
221 // Assigns |state_| to |state| | 221 // Assigns |state_| to |state| |
222 void ChangeState_Locked(State state); | 222 void ChangeState_Locked(State state); |
223 | 223 |
224 // Adds the callback to |read_cbs_| so it can be called later when we | 224 // Adds the callback to |read_cbs_| so it can be called later when we |
225 // have data. | 225 // have data. |
226 void DeferRead_Locked(const ReadCB& read_cb); | 226 void DeferRead_Locked(const ReadCB& read_cb); |
227 | 227 |
228 // Creates closures that bind ReadCBs in |read_cbs_| to data in | 228 // Creates closures that bind ReadCBs in |read_cbs_| to data in |
229 // |buffers_| and pops the callbacks & buffers from the respecive queues. | 229 // |buffers_| and pops the callbacks & buffers from the respective queues. |
230 void CreateReadDoneClosures_Locked(ClosureQueue* closures); | 230 void CreateReadDoneClosures_Locked(ClosureQueue* closures); |
231 | 231 |
232 // Gets the value to pass to the next Read() callback. Returns true if | 232 // Gets the value to pass to the next Read() callback. Returns true if |
233 // |status| and |buffer| should be passed to the callback. False indicates | 233 // |status| and |buffer| should be passed to the callback. False indicates |
234 // that |status| and |buffer| were not set and more data is needed. | 234 // that |status| and |buffer| were not set and more data is needed. |
235 bool GetNextBuffer_Locked(DemuxerStream::Status* status, | 235 bool GetNextBuffer_Locked(DemuxerStream::Status* status, |
236 scoped_refptr<StreamParserBuffer>* buffer); | 236 scoped_refptr<StreamParserBuffer>* buffer); |
237 | 237 |
238 // Specifies the type of the stream (must be AUDIO or VIDEO for now). | 238 // Specifies the type of the stream (must be AUDIO or VIDEO for now). |
239 Type type_; | 239 Type type_; |
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1007 | 1007 |
1008 if (video_) | 1008 if (video_) |
1009 video_->Seek(TimeDelta()); | 1009 video_->Seek(TimeDelta()); |
1010 | 1010 |
1011 if (duration_ == TimeDelta()) | 1011 if (duration_ == TimeDelta()) |
1012 duration_ = kInfiniteDuration(); | 1012 duration_ = kInfiniteDuration(); |
1013 | 1013 |
1014 // The demuxer is now initialized after the |start_timestamp_| was set. | 1014 // The demuxer is now initialized after the |start_timestamp_| was set. |
1015 ChangeState_Locked(INITIALIZED); | 1015 ChangeState_Locked(INITIALIZED); |
1016 base::ResetAndReturn(&init_cb_).Run(PIPELINE_OK); | 1016 base::ResetAndReturn(&init_cb_).Run(PIPELINE_OK); |
1017 | |
1018 } | 1017 } |
1019 | 1018 |
1020 bool ChunkDemuxer::OnNewConfigs(bool has_audio, bool has_video, | 1019 bool ChunkDemuxer::OnNewConfigs(bool has_audio, bool has_video, |
1021 const AudioDecoderConfig& audio_config, | 1020 const AudioDecoderConfig& audio_config, |
1022 const VideoDecoderConfig& video_config) { | 1021 const VideoDecoderConfig& video_config) { |
1023 DVLOG(1) << "OnNewConfigs(" << has_audio << ", " << has_video | 1022 DVLOG(1) << "OnNewConfigs(" << has_audio << ", " << has_video |
1024 << ", " << audio_config.IsValidConfig() | 1023 << ", " << audio_config.IsValidConfig() |
1025 << ", " << video_config.IsValidConfig() << ")"; | 1024 << ", " << video_config.IsValidConfig() << ")"; |
1026 lock_.AssertAcquired(); | 1025 lock_.AssertAcquired(); |
1027 | 1026 |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1187 | 1186 |
1188 Ranges<TimeDelta> ChunkDemuxer::GetBufferedRanges() const { | 1187 Ranges<TimeDelta> ChunkDemuxer::GetBufferedRanges() const { |
1189 if (audio_ && !video_) | 1188 if (audio_ && !video_) |
1190 return audio_->GetBufferedRanges(duration_); | 1189 return audio_->GetBufferedRanges(duration_); |
1191 else if (!audio_ && video_) | 1190 else if (!audio_ && video_) |
1192 return video_->GetBufferedRanges(duration_); | 1191 return video_->GetBufferedRanges(duration_); |
1193 return ComputeIntersection(); | 1192 return ComputeIntersection(); |
1194 } | 1193 } |
1195 | 1194 |
1196 } // namespace media | 1195 } // namespace media |
OLD | NEW |