| OLD | NEW | 
|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "content/renderer/media/webmediasource_impl.h" | 5 #include "content/renderer/media/webmediasource_impl.h" | 
| 6 | 6 | 
|  | 7 #include "base/bind.h" | 
| 7 #include "base/guid.h" | 8 #include "base/guid.h" | 
| 8 #include "content/renderer/media/websourcebuffer_impl.h" | 9 #include "content/renderer/media/websourcebuffer_impl.h" | 
| 9 #include "media/filters/chunk_demuxer.h" | 10 #include "media/filters/chunk_demuxer.h" | 
| 10 #include "third_party/WebKit/public/platform/WebCString.h" | 11 #include "third_party/WebKit/public/platform/WebCString.h" | 
| 11 #include "third_party/WebKit/public/platform/WebString.h" | 12 #include "third_party/WebKit/public/platform/WebString.h" | 
| 12 | 13 | 
| 13 using ::blink::WebString; | 14 using ::blink::WebString; | 
| 14 using ::blink::WebMediaSource; | 15 using ::blink::WebMediaSource; | 
| 15 | 16 | 
| 16 namespace content { | 17 namespace content { | 
| (...skipping 18 matching lines...) Expand all  Loading... | 
| 35 | 36 | 
| 36 WebMediaSource::AddStatus WebMediaSourceImpl::addSourceBuffer( | 37 WebMediaSource::AddStatus WebMediaSourceImpl::addSourceBuffer( | 
| 37     const blink::WebString& type, | 38     const blink::WebString& type, | 
| 38     const blink::WebVector<blink::WebString>& codecs, | 39     const blink::WebVector<blink::WebString>& codecs, | 
| 39     blink::WebSourceBuffer** source_buffer) { | 40     blink::WebSourceBuffer** source_buffer) { | 
| 40   std::string id = base::GenerateGUID(); | 41   std::string id = base::GenerateGUID(); | 
| 41   std::vector<std::string> new_codecs(codecs.size()); | 42   std::vector<std::string> new_codecs(codecs.size()); | 
| 42   for (size_t i = 0; i < codecs.size(); ++i) | 43   for (size_t i = 0; i < codecs.size(); ++i) | 
| 43     new_codecs[i] = codecs[i].utf8().data(); | 44     new_codecs[i] = codecs[i].utf8().data(); | 
| 44 | 45 | 
|  | 46   scoped_ptr<WebSourceBufferImpl> web_source_buffer( | 
|  | 47       new WebSourceBufferImpl(id, demuxer_)); | 
|  | 48 | 
| 45   WebMediaSource::AddStatus result = | 49   WebMediaSource::AddStatus result = | 
| 46       static_cast<WebMediaSource::AddStatus>( | 50       static_cast<WebMediaSource::AddStatus>( | 
| 47           demuxer_->AddId(id, type.utf8().data(), new_codecs)); | 51           demuxer_->AddId( | 
|  | 52               id, | 
|  | 53               type.utf8().data(), | 
|  | 54               new_codecs, | 
|  | 55               base::Bind(&WebSourceBufferImpl::OnNewInitSegment, | 
|  | 56                          base::Unretained(web_source_buffer.get())))); | 
| 48 | 57 | 
| 49   if (result == WebMediaSource::AddStatusOk) | 58   if (result == WebMediaSource::AddStatusOk) | 
| 50     *source_buffer = new WebSourceBufferImpl(id, demuxer_); | 59     *source_buffer = web_source_buffer.release(); | 
| 51 | 60 | 
| 52   return result; | 61   return result; | 
| 53 } | 62 } | 
| 54 | 63 | 
| 55 double WebMediaSourceImpl::duration() { | 64 double WebMediaSourceImpl::duration() { | 
| 56   return demuxer_->GetDuration(); | 65   return demuxer_->GetDuration(); | 
| 57 } | 66 } | 
| 58 | 67 | 
| 59 void WebMediaSourceImpl::setDuration(double new_duration) { | 68 void WebMediaSourceImpl::setDuration(double new_duration) { | 
| 60   DCHECK_GE(new_duration, 0); | 69   DCHECK_GE(new_duration, 0); | 
| (...skipping 16 matching lines...) Expand all  Loading... | 
| 77   } | 86   } | 
| 78 | 87 | 
| 79   demuxer_->MarkEndOfStream(pipeline_status); | 88   demuxer_->MarkEndOfStream(pipeline_status); | 
| 80 } | 89 } | 
| 81 | 90 | 
| 82 void WebMediaSourceImpl::unmarkEndOfStream() { | 91 void WebMediaSourceImpl::unmarkEndOfStream() { | 
| 83   demuxer_->UnmarkEndOfStream(); | 92   demuxer_->UnmarkEndOfStream(); | 
| 84 } | 93 } | 
| 85 | 94 | 
| 86 }  // namespace content | 95 }  // namespace content | 
| OLD | NEW | 
|---|