| 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 "media/blink/webmediasource_impl.h" | 5 #include "media/blink/webmediasource_impl.h" |
| 6 | 6 |
| 7 #include "base/guid.h" | 7 #include "base/guid.h" |
| 8 #include "media/base/mime_util.h" |
| 8 #include "media/blink/websourcebuffer_impl.h" | 9 #include "media/blink/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 media { | 17 namespace media { |
| 17 | 18 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 44 WebMediaSource::AddStatus result = | 45 WebMediaSource::AddStatus result = |
| 45 static_cast<WebMediaSource::AddStatus>( | 46 static_cast<WebMediaSource::AddStatus>( |
| 46 demuxer_->AddId(id, type.utf8().data(), new_codecs)); | 47 demuxer_->AddId(id, type.utf8().data(), new_codecs)); |
| 47 | 48 |
| 48 if (result == WebMediaSource::AddStatusOk) | 49 if (result == WebMediaSource::AddStatusOk) |
| 49 *source_buffer = new WebSourceBufferImpl(id, demuxer_); | 50 *source_buffer = new WebSourceBufferImpl(id, demuxer_); |
| 50 | 51 |
| 51 return result; | 52 return result; |
| 52 } | 53 } |
| 53 | 54 |
| 55 WebMediaSource::AddStatus WebMediaSourceImpl::addSourceBuffer( |
| 56 const blink::WebString& type, |
| 57 const blink::WebString& codecs, |
| 58 blink::WebSourceBuffer** source_buffer) { |
| 59 std::string id = base::GenerateGUID(); |
| 60 |
| 61 std::vector<std::string> parsed_codec_ids; |
| 62 media::ParseCodecString(codecs.utf8().data(), &parsed_codec_ids, false); |
| 63 |
| 64 WebMediaSource::AddStatus result = |
| 65 static_cast<WebMediaSource::AddStatus>( |
| 66 demuxer_->AddId(id, type.utf8().data(), parsed_codec_ids)); |
| 67 |
| 68 if (result == WebMediaSource::AddStatusOk) |
| 69 *source_buffer = new WebSourceBufferImpl(id, demuxer_); |
| 70 |
| 71 return result; |
| 72 } |
| 73 |
| 54 double WebMediaSourceImpl::duration() { | 74 double WebMediaSourceImpl::duration() { |
| 55 return demuxer_->GetDuration(); | 75 return demuxer_->GetDuration(); |
| 56 } | 76 } |
| 57 | 77 |
| 58 void WebMediaSourceImpl::setDuration(double new_duration) { | 78 void WebMediaSourceImpl::setDuration(double new_duration) { |
| 59 DCHECK_GE(new_duration, 0); | 79 DCHECK_GE(new_duration, 0); |
| 60 demuxer_->SetDuration(new_duration); | 80 demuxer_->SetDuration(new_duration); |
| 61 } | 81 } |
| 62 | 82 |
| 63 void WebMediaSourceImpl::markEndOfStream( | 83 void WebMediaSourceImpl::markEndOfStream( |
| (...skipping 12 matching lines...) Expand all Loading... |
| 76 } | 96 } |
| 77 | 97 |
| 78 demuxer_->MarkEndOfStream(pipeline_status); | 98 demuxer_->MarkEndOfStream(pipeline_status); |
| 79 } | 99 } |
| 80 | 100 |
| 81 void WebMediaSourceImpl::unmarkEndOfStream() { | 101 void WebMediaSourceImpl::unmarkEndOfStream() { |
| 82 demuxer_->UnmarkEndOfStream(); | 102 demuxer_->UnmarkEndOfStream(); |
| 83 } | 103 } |
| 84 | 104 |
| 85 } // namespace media | 105 } // namespace media |
| OLD | NEW |