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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 // and |has_video| are undefined. | 92 // and |has_video| are undefined. |
93 static bool IsSupported(const std::string& type, | 93 static bool IsSupported(const std::string& type, |
94 std::vector<std::string>& codecs, | 94 std::vector<std::string>& codecs, |
95 ParserFactoryFunction* factory_function, | 95 ParserFactoryFunction* factory_function, |
96 bool* has_audio, | 96 bool* has_audio, |
97 bool* has_video) { | 97 bool* has_video) { |
98 *factory_function = NULL; | 98 *factory_function = NULL; |
99 *has_audio = false; | 99 *has_audio = false; |
100 *has_video = false; | 100 *has_video = false; |
101 | 101 |
102 // Search for the SupportedTypeInfo for |type| | 102 // Search for the SupportedTypeInfo for |type|. |
103 for (size_t i = 0; i < arraysize(kSupportedTypeInfo); ++i) { | 103 for (size_t i = 0; i < arraysize(kSupportedTypeInfo); ++i) { |
104 const SupportedTypeInfo& type_info = kSupportedTypeInfo[i]; | 104 const SupportedTypeInfo& type_info = kSupportedTypeInfo[i]; |
105 if (type == type_info.type) { | 105 if (type == type_info.type) { |
106 // Make sure all the codecs specified in |codecs| are | 106 // Make sure all the codecs specified in |codecs| are |
107 // in the supported type info. | 107 // in the supported type info. |
108 for (size_t j = 0; j < codecs.size(); ++j) { | 108 for (size_t j = 0; j < codecs.size(); ++j) { |
109 // Search the type info for a match. | 109 // Search the type info for a match. |
110 bool found_codec = false; | 110 bool found_codec = false; |
111 DemuxerStream::Type codec_type = DemuxerStream::UNKNOWN; | 111 DemuxerStream::Type codec_type = DemuxerStream::UNKNOWN; |
112 | 112 |
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
752 } | 752 } |
753 | 753 |
754 void ChunkDemuxer::Abort(const std::string& id) { | 754 void ChunkDemuxer::Abort(const std::string& id) { |
755 DVLOG(1) << "Abort(" << id << ")"; | 755 DVLOG(1) << "Abort(" << id << ")"; |
756 DCHECK(!id.empty()); | 756 DCHECK(!id.empty()); |
757 DCHECK_GT(stream_parser_map_.count(id), 0u); | 757 DCHECK_GT(stream_parser_map_.count(id), 0u); |
758 | 758 |
759 stream_parser_map_[id]->Flush(); | 759 stream_parser_map_[id]->Flush(); |
760 } | 760 } |
761 | 761 |
| 762 void ChunkDemuxer::TimestampOffset(const std::string& id, float offset) { |
| 763 DVLOG(1) << "TimestampOffset(" << id << ", " << offset << ")"; |
| 764 DCHECK_GT(stream_parser_map_.count(id), 0u); |
| 765 |
| 766 TimeDelta time_offset = TimeDelta::FromMicroseconds( |
| 767 offset * base::Time::kMicrosecondsPerSecond); |
| 768 stream_parser_map_[id]->SetTimestampOffset(time_offset); |
| 769 } |
| 770 |
| 771 void ChunkDemuxer::ClearTimestampOffset(const std::string& id) { |
| 772 DVLOG(1) << "ClearTimestampOffset(" << id << ")"; |
| 773 DCHECK_GT(stream_parser_map_.count(id), 0u); |
| 774 |
| 775 stream_parser_map_[id]->ClearTimestampOffset(); |
| 776 } |
| 777 |
762 bool ChunkDemuxer::EndOfStream(PipelineStatus status) { | 778 bool ChunkDemuxer::EndOfStream(PipelineStatus status) { |
763 DVLOG(1) << "EndOfStream(" << status << ")"; | 779 DVLOG(1) << "EndOfStream(" << status << ")"; |
764 base::AutoLock auto_lock(lock_); | 780 base::AutoLock auto_lock(lock_); |
765 DCHECK_NE(state_, WAITING_FOR_INIT); | 781 DCHECK_NE(state_, WAITING_FOR_INIT); |
766 DCHECK_NE(state_, ENDED); | 782 DCHECK_NE(state_, ENDED); |
767 | 783 |
768 if (state_ == SHUTDOWN || state_ == PARSE_ERROR) | 784 if (state_ == SHUTDOWN || state_ == PARSE_ERROR) |
769 return true; | 785 return true; |
770 | 786 |
771 if (state_ == INITIALIZING) { | 787 if (state_ == INITIALIZING) { |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1011 video_->SetStartTime(start_time_); | 1027 video_->SetStartTime(start_time_); |
1012 video_->Seek(start_time_); | 1028 video_->Seek(start_time_); |
1013 } | 1029 } |
1014 | 1030 |
1015 // The demuxer is now initialized after the |start_timestamp_| was set. | 1031 // The demuxer is now initialized after the |start_timestamp_| was set. |
1016 ChangeState_Locked(INITIALIZED); | 1032 ChangeState_Locked(INITIALIZED); |
1017 base::ResetAndReturn(&init_cb_).Run(PIPELINE_OK); | 1033 base::ResetAndReturn(&init_cb_).Run(PIPELINE_OK); |
1018 } | 1034 } |
1019 | 1035 |
1020 } // namespace media | 1036 } // namespace media |
OLD | NEW |