| 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 <limits> |     8 #include <limits> | 
|     9 #include <list> |     9 #include <list> | 
|    10  |    10  | 
|    11 #include "base/bind.h" |    11 #include "base/bind.h" | 
 |    12 #include "base/bind_to_current_loop.h" | 
|    12 #include "base/callback_helpers.h" |    13 #include "base/callback_helpers.h" | 
|    13 #include "base/location.h" |    14 #include "base/location.h" | 
|    14 #include "base/message_loop/message_loop_proxy.h" |    15 #include "base/message_loop/message_loop_proxy.h" | 
|    15 #include "base/stl_util.h" |    16 #include "base/stl_util.h" | 
|    16 #include "media/base/audio_decoder_config.h" |    17 #include "media/base/audio_decoder_config.h" | 
|    17 #include "media/base/bind_to_current_loop.h" |  | 
|    18 #include "media/base/stream_parser_buffer.h" |    18 #include "media/base/stream_parser_buffer.h" | 
|    19 #include "media/base/video_decoder_config.h" |    19 #include "media/base/video_decoder_config.h" | 
|    20 #include "media/filters/frame_processor.h" |    20 #include "media/filters/frame_processor.h" | 
|    21 #include "media/filters/stream_parser_factory.h" |    21 #include "media/filters/stream_parser_factory.h" | 
|    22  |    22  | 
|    23 using base::TimeDelta; |    23 using base::TimeDelta; | 
|    24  |    24  | 
|    25 namespace media { |    25 namespace media { | 
|    26  |    26  | 
|    27 static TimeDelta EndTimestamp(const StreamParser::BufferQueue& queue) { |    27 static TimeDelta EndTimestamp(const StreamParser::BufferQueue& queue) { | 
| (...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   985   base::AutoLock auto_lock(lock_); |   985   base::AutoLock auto_lock(lock_); | 
|   986   stream_->UnmarkEndOfStream(); |   986   stream_->UnmarkEndOfStream(); | 
|   987 } |   987 } | 
|   988  |   988  | 
|   989 // DemuxerStream methods. |   989 // DemuxerStream methods. | 
|   990 void ChunkDemuxerStream::Read(const ReadCB& read_cb) { |   990 void ChunkDemuxerStream::Read(const ReadCB& read_cb) { | 
|   991   base::AutoLock auto_lock(lock_); |   991   base::AutoLock auto_lock(lock_); | 
|   992   DCHECK_NE(state_, UNINITIALIZED); |   992   DCHECK_NE(state_, UNINITIALIZED); | 
|   993   DCHECK(read_cb_.is_null()); |   993   DCHECK(read_cb_.is_null()); | 
|   994  |   994  | 
|   995   read_cb_ = BindToCurrentLoop(read_cb); |   995   read_cb_ = base::BindToCurrentLoop(read_cb); | 
|   996   CompletePendingReadIfPossible_Locked(); |   996   CompletePendingReadIfPossible_Locked(); | 
|   997 } |   997 } | 
|   998  |   998  | 
|   999 DemuxerStream::Type ChunkDemuxerStream::type() const { return type_; } |   999 DemuxerStream::Type ChunkDemuxerStream::type() const { return type_; } | 
|  1000  |  1000  | 
|  1001 DemuxerStream::Liveness ChunkDemuxerStream::liveness() const { |  1001 DemuxerStream::Liveness ChunkDemuxerStream::liveness() const { | 
|  1002   base::AutoLock auto_lock(lock_); |  1002   base::AutoLock auto_lock(lock_); | 
|  1003   return liveness_; |  1003   return liveness_; | 
|  1004 } |  1004 } | 
|  1005  |  1005  | 
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1126  |  1126  | 
|  1127 void ChunkDemuxer::Initialize( |  1127 void ChunkDemuxer::Initialize( | 
|  1128     DemuxerHost* host, |  1128     DemuxerHost* host, | 
|  1129     const PipelineStatusCB& cb, |  1129     const PipelineStatusCB& cb, | 
|  1130     bool enable_text_tracks) { |  1130     bool enable_text_tracks) { | 
|  1131   DVLOG(1) << "Init()"; |  1131   DVLOG(1) << "Init()"; | 
|  1132  |  1132  | 
|  1133   base::AutoLock auto_lock(lock_); |  1133   base::AutoLock auto_lock(lock_); | 
|  1134  |  1134  | 
|  1135   // The |init_cb_| must only be run after this method returns, so always post. |  1135   // The |init_cb_| must only be run after this method returns, so always post. | 
|  1136   init_cb_ = BindToCurrentLoop(cb); |  1136   init_cb_ = base::BindToCurrentLoop(cb); | 
|  1137   if (state_ == SHUTDOWN) { |  1137   if (state_ == SHUTDOWN) { | 
|  1138     base::ResetAndReturn(&init_cb_).Run(DEMUXER_ERROR_COULD_NOT_OPEN); |  1138     base::ResetAndReturn(&init_cb_).Run(DEMUXER_ERROR_COULD_NOT_OPEN); | 
|  1139     return; |  1139     return; | 
|  1140   } |  1140   } | 
|  1141   DCHECK_EQ(state_, WAITING_FOR_INIT); |  1141   DCHECK_EQ(state_, WAITING_FOR_INIT); | 
|  1142   host_ = host; |  1142   host_ = host; | 
|  1143   enable_text_ = enable_text_tracks; |  1143   enable_text_ = enable_text_tracks; | 
|  1144  |  1144  | 
|  1145   ChangeState_Locked(INITIALIZING); |  1145   ChangeState_Locked(INITIALIZING); | 
|  1146  |  1146  | 
|  1147   base::ResetAndReturn(&open_cb_).Run(); |  1147   base::ResetAndReturn(&open_cb_).Run(); | 
|  1148 } |  1148 } | 
|  1149  |  1149  | 
|  1150 void ChunkDemuxer::Stop() { |  1150 void ChunkDemuxer::Stop() { | 
|  1151   DVLOG(1) << "Stop()"; |  1151   DVLOG(1) << "Stop()"; | 
|  1152   Shutdown(); |  1152   Shutdown(); | 
|  1153 } |  1153 } | 
|  1154  |  1154  | 
|  1155 void ChunkDemuxer::Seek(TimeDelta time, const PipelineStatusCB& cb) { |  1155 void ChunkDemuxer::Seek(TimeDelta time, const PipelineStatusCB& cb) { | 
|  1156   DVLOG(1) << "Seek(" << time.InSecondsF() << ")"; |  1156   DVLOG(1) << "Seek(" << time.InSecondsF() << ")"; | 
|  1157   DCHECK(time >= TimeDelta()); |  1157   DCHECK(time >= TimeDelta()); | 
|  1158  |  1158  | 
|  1159   base::AutoLock auto_lock(lock_); |  1159   base::AutoLock auto_lock(lock_); | 
|  1160   DCHECK(seek_cb_.is_null()); |  1160   DCHECK(seek_cb_.is_null()); | 
|  1161  |  1161  | 
|  1162   seek_cb_ = BindToCurrentLoop(cb); |  1162   seek_cb_ = base::BindToCurrentLoop(cb); | 
|  1163   if (state_ != INITIALIZED && state_ != ENDED) { |  1163   if (state_ != INITIALIZED && state_ != ENDED) { | 
|  1164     base::ResetAndReturn(&seek_cb_).Run(PIPELINE_ERROR_INVALID_STATE); |  1164     base::ResetAndReturn(&seek_cb_).Run(PIPELINE_ERROR_INVALID_STATE); | 
|  1165     return; |  1165     return; | 
|  1166   } |  1166   } | 
|  1167  |  1167  | 
|  1168   if (cancel_next_seek_) { |  1168   if (cancel_next_seek_) { | 
|  1169     cancel_next_seek_ = false; |  1169     cancel_next_seek_ = false; | 
|  1170     base::ResetAndReturn(&seek_cb_).Run(PIPELINE_OK); |  1170     base::ResetAndReturn(&seek_cb_).Run(PIPELINE_OK); | 
|  1171     return; |  1171     return; | 
|  1172   } |  1172   } | 
| (...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1840 } |  1840 } | 
|  1841  |  1841  | 
|  1842 void ChunkDemuxer::ShutdownAllStreams() { |  1842 void ChunkDemuxer::ShutdownAllStreams() { | 
|  1843   for (SourceStateMap::iterator itr = source_state_map_.begin(); |  1843   for (SourceStateMap::iterator itr = source_state_map_.begin(); | 
|  1844        itr != source_state_map_.end(); ++itr) { |  1844        itr != source_state_map_.end(); ++itr) { | 
|  1845     itr->second->Shutdown(); |  1845     itr->second->Shutdown(); | 
|  1846   } |  1846   } | 
|  1847 } |  1847 } | 
|  1848  |  1848  | 
|  1849 }  // namespace media |  1849 }  // namespace media | 
| OLD | NEW |