| 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 std::string& type, |
| 90 const std::vector<std::string>& codecs) { |
| 91 return media::StreamParserFactory::IsTypeSupported(type, codecs); |
| 92 } |
| 93 |
| 87 WebMediaSourceClientImpl::WebMediaSourceClientImpl( | 94 WebMediaSourceClientImpl::WebMediaSourceClientImpl( |
| 88 const scoped_refptr<media::ChunkDemuxer>& demuxer) | 95 const scoped_refptr<media::ChunkDemuxer>& demuxer, |
| 89 : demuxer_(demuxer) { | 96 media::LogCB log_cb) |
| 97 : demuxer_(demuxer), |
| 98 log_cb_(log_cb) { |
| 90 DCHECK(demuxer_); | 99 DCHECK(demuxer_); |
| 91 } | 100 } |
| 92 | 101 |
| 93 WebMediaSourceClientImpl::~WebMediaSourceClientImpl() {} | 102 WebMediaSourceClientImpl::~WebMediaSourceClientImpl() {} |
| 94 | 103 |
| 95 WebMediaSourceClient::AddStatus WebMediaSourceClientImpl::addSourceBuffer( | 104 WebMediaSourceClient::AddStatus WebMediaSourceClientImpl::addSourceBuffer( |
| 96 const WebKit::WebString& type, | 105 const WebKit::WebString& type, |
| 97 const WebKit::WebVector<WebKit::WebString>& codecs, | 106 const WebKit::WebVector<WebKit::WebString>& codecs, |
| 98 WebKit::WebSourceBuffer** source_buffer) { | 107 WebKit::WebSourceBuffer** source_buffer) { |
| 99 std::string id = base::GenerateGUID(); | 108 std::string id = base::GenerateGUID(); |
| 100 std::vector<std::string> new_codecs(codecs.size()); | 109 std::vector<std::string> new_codecs(codecs.size()); |
| 101 for (size_t i = 0; i < codecs.size(); ++i) | 110 for (size_t i = 0; i < codecs.size(); ++i) |
| 102 new_codecs[i] = codecs[i].utf8().data(); | 111 new_codecs[i] = codecs[i].utf8().data(); |
| 103 | 112 DCHECK(isTypeSupported(type.utf8().data(), new_codecs)); |
| 104 WebMediaSourceClient::AddStatus result = | 113 WebMediaSourceClient::AddStatus result = |
| 105 static_cast<WebMediaSourceClient::AddStatus>( | 114 static_cast<WebMediaSourceClient::AddStatus>( |
| 106 demuxer_->AddId(id, type.utf8().data(), new_codecs)); | 115 demuxer_->AddId(id, type.utf8().data(), new_codecs)); |
| 107 | 116 |
| 108 if (result == WebMediaSourceClient::AddStatusOk) | 117 if (result == WebMediaSourceClient::AddStatusOk) |
| 109 *source_buffer = new WebSourceBufferImpl(id, demuxer_); | 118 *source_buffer = new WebSourceBufferImpl(id, demuxer_); |
| 110 | 119 |
| 111 return result; | 120 return result; |
| 112 } | 121 } |
| 113 | 122 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 break; | 159 break; |
| 151 default: | 160 default: |
| 152 NOTIMPLEMENTED(); | 161 NOTIMPLEMENTED(); |
| 153 } | 162 } |
| 154 | 163 |
| 155 if (!demuxer_->EndOfStream(pipeline_status)) | 164 if (!demuxer_->EndOfStream(pipeline_status)) |
| 156 DVLOG(1) << "EndOfStream call failed."; | 165 DVLOG(1) << "EndOfStream call failed."; |
| 157 } | 166 } |
| 158 | 167 |
| 159 } // namespace webkit_media | 168 } // namespace webkit_media |
| OLD | NEW |