OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "webkit/media/webmediasourceclient_impl.h" | 5 #include "webkit/media/webmediasourceclient_impl.h" |
6 | 6 |
7 #include "base/guid.h" | 7 #include "base/guid.h" |
8 #include "media/filters/chunk_demuxer.h" | 8 #include "media/filters/chunk_demuxer.h" |
9 #include "media/filters/stream_parser_factory.h" | |
9 #include "third_party/WebKit/Source/Platform/chromium/public/WebCString.h" | 10 #include "third_party/WebKit/Source/Platform/chromium/public/WebCString.h" |
10 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" | 11 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" |
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSourceBuffer.h" | 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSourceBuffer.h" |
12 | 13 |
13 using ::WebKit::WebString; | 14 using ::WebKit::WebString; |
14 using ::WebKit::WebMediaSourceClient; | 15 using ::WebKit::WebMediaSourceClient; |
15 | 16 |
16 namespace webkit_media { | 17 namespace webkit_media { |
17 | 18 |
18 #define COMPILE_ASSERT_MATCHING_STATUS_ENUM(webkit_name, chromium_name) \ | 19 #define COMPILE_ASSERT_MATCHING_STATUS_ENUM(webkit_name, chromium_name) \ |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
77 base::TimeDelta time_offset = base::TimeDelta::FromMicroseconds( | 78 base::TimeDelta time_offset = base::TimeDelta::FromMicroseconds( |
78 offset * base::Time::kMicrosecondsPerSecond); | 79 offset * base::Time::kMicrosecondsPerSecond); |
79 return demuxer_->SetTimestampOffset(id_, time_offset); | 80 return demuxer_->SetTimestampOffset(id_, time_offset); |
80 } | 81 } |
81 | 82 |
82 void WebSourceBufferImpl::removedFromMediaSource() { | 83 void WebSourceBufferImpl::removedFromMediaSource() { |
83 demuxer_->RemoveId(id_); | 84 demuxer_->RemoveId(id_); |
84 demuxer_ = NULL; | 85 demuxer_ = NULL; |
85 } | 86 } |
86 | 87 |
88 bool WebMediaSourceClientImpl::isTypeSupported( | |
89 const WebKit::WebString& type, | |
90 const WebKit::WebVector<WebKit::WebString>& codecs) { | |
91 std::vector<std::string> new_codecs(codecs.size()); | |
92 for (size_t i = 0; i < codecs.size(); ++i) | |
93 new_codecs[i] = codecs[i].utf8().data(); | |
94 return media::StreamParserFactory::IsTypeSupported(type.utf8().data(), | |
95 new_codecs); | |
96 } | |
97 | |
87 WebMediaSourceClientImpl::WebMediaSourceClientImpl( | 98 WebMediaSourceClientImpl::WebMediaSourceClientImpl( |
88 const scoped_refptr<media::ChunkDemuxer>& demuxer) | 99 const scoped_refptr<media::ChunkDemuxer>& demuxer, |
89 : demuxer_(demuxer) { | 100 media::LogCB log_cb) |
101 : demuxer_(demuxer), | |
102 log_cb_(log_cb) { | |
90 DCHECK(demuxer_); | 103 DCHECK(demuxer_); |
91 } | 104 } |
92 | 105 |
93 WebMediaSourceClientImpl::~WebMediaSourceClientImpl() {} | 106 WebMediaSourceClientImpl::~WebMediaSourceClientImpl() {} |
94 | 107 |
95 WebMediaSourceClient::AddStatus WebMediaSourceClientImpl::addSourceBuffer( | 108 WebMediaSourceClient::AddStatus WebMediaSourceClientImpl::addSourceBuffer( |
96 const WebKit::WebString& type, | 109 const WebKit::WebString& type, |
97 const WebKit::WebVector<WebKit::WebString>& codecs, | 110 const WebKit::WebVector<WebKit::WebString>& codecs, |
98 WebKit::WebSourceBuffer** source_buffer) { | 111 WebKit::WebSourceBuffer** source_buffer) { |
112 DCHECK(isTypeSupported(type, codecs)); | |
113 | |
99 std::string id = base::GenerateGUID(); | 114 std::string id = base::GenerateGUID(); |
115 bool has_audio = false; | |
116 bool has_video = false; | |
100 std::vector<std::string> new_codecs(codecs.size()); | 117 std::vector<std::string> new_codecs(codecs.size()); |
101 for (size_t i = 0; i < codecs.size(); ++i) | 118 for (size_t i = 0; i < codecs.size(); ++i) |
102 new_codecs[i] = codecs[i].utf8().data(); | 119 new_codecs[i] = codecs[i].utf8().data(); |
120 scoped_ptr<media::StreamParser> stream_parser( | |
121 media::StreamParserFactory::Create(type.utf8().data(), new_codecs, | |
122 log_cb_, &has_audio, &has_video)); | |
123 | |
124 if (!stream_parser) | |
125 return AddStatusNotSupported; | |
103 | 126 |
104 WebMediaSourceClient::AddStatus result = | 127 WebMediaSourceClient::AddStatus result = |
105 static_cast<WebMediaSourceClient::AddStatus>( | 128 static_cast<WebMediaSourceClient::AddStatus>( |
106 demuxer_->AddId(id, type.utf8().data(), new_codecs)); | 129 demuxer_->AddParser(id, stream_parser.Pass(), has_audio, has_video)); |
scherkus (not reviewing)
2013/03/14 01:15:26
where is ChunkDemuxer::AddParser() defined? I'm no
acolwell GONE FROM CHROMIUM
2013/03/14 18:34:34
This was accidentally left in for a refactor that
| |
107 | 130 |
108 if (result == WebMediaSourceClient::AddStatusOk) | 131 if (result == WebMediaSourceClient::AddStatusOk) |
109 *source_buffer = new WebSourceBufferImpl(id, demuxer_); | 132 *source_buffer = new WebSourceBufferImpl(id, demuxer_); |
110 | 133 |
111 return result; | 134 return result; |
112 } | 135 } |
113 | 136 |
114 double WebMediaSourceClientImpl::duration() { | 137 double WebMediaSourceClientImpl::duration() { |
115 double duration = demuxer_->GetDuration(); | 138 double duration = demuxer_->GetDuration(); |
116 | 139 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
150 break; | 173 break; |
151 default: | 174 default: |
152 NOTIMPLEMENTED(); | 175 NOTIMPLEMENTED(); |
153 } | 176 } |
154 | 177 |
155 if (!demuxer_->EndOfStream(pipeline_status)) | 178 if (!demuxer_->EndOfStream(pipeline_status)) |
156 DVLOG(1) << "EndOfStream call failed."; | 179 DVLOG(1) << "EndOfStream call failed."; |
157 } | 180 } |
158 | 181 |
159 } // namespace webkit_media | 182 } // namespace webkit_media |
OLD | NEW |