Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(421)

Side by Side Diff: media/blink/webmediaplayer_impl.cc

Issue 1735763002: Pass ffmpeg media track info to HTMLMediaElement (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@demuxer-tracks
Patch Set: rebase Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/media/avtrack/audio-track-properties.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/webmediaplayer_impl.h" 5 #include "media/blink/webmediaplayer_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <limits> 9 #include <limits>
10 #include <string> 10 #include <string>
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 #if defined(OS_ANDROID) // WMPI_CAST 184 #if defined(OS_ANDROID) // WMPI_CAST
185 cast_impl_(this, client_, params.context_3d_cb()), 185 cast_impl_(this, client_, params.context_3d_cb()),
186 #endif 186 #endif
187 volume_(1.0), 187 volume_(1.0),
188 volume_multiplier_(1.0), 188 volume_multiplier_(1.0),
189 renderer_factory_(std::move(renderer_factory)), 189 renderer_factory_(std::move(renderer_factory)),
190 surface_manager_(params.surface_manager()), 190 surface_manager_(params.surface_manager()),
191 suppress_destruction_errors_(false) { 191 suppress_destruction_errors_(false) {
192 DCHECK(!adjust_allocated_memory_cb_.is_null()); 192 DCHECK(!adjust_allocated_memory_cb_.is_null());
193 DCHECK(renderer_factory_); 193 DCHECK(renderer_factory_);
194 DCHECK(client_);
194 195
195 if (delegate_) 196 if (delegate_)
196 delegate_id_ = delegate_->AddObserver(this); 197 delegate_id_ = delegate_->AddObserver(this);
197 198
198 media_log_->AddEvent( 199 media_log_->AddEvent(
199 media_log_->CreateEvent(MediaLogEvent::WEBMEDIAPLAYER_CREATED)); 200 media_log_->CreateEvent(MediaLogEvent::WEBMEDIAPLAYER_CREATED));
200 201
201 if (params.initial_cdm()) { 202 if (params.initial_cdm()) {
202 SetCdm(base::Bind(&IgnoreCdmAttached), 203 SetCdm(base::Bind(&IgnoreCdmAttached),
203 ToWebContentDecryptionModuleImpl(params.initial_cdm()) 204 ToWebContentDecryptionModuleImpl(params.initial_cdm())
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 ConvertToWebInitDataType(init_data_type), init_data.data(), 797 ConvertToWebInitDataType(init_data_type), init_data.data(),
797 base::saturated_cast<unsigned int>(init_data.size())); 798 base::saturated_cast<unsigned int>(init_data.size()));
798 } 799 }
799 800
800 void WebMediaPlayerImpl::OnFFmpegMediaTracksUpdated( 801 void WebMediaPlayerImpl::OnFFmpegMediaTracksUpdated(
801 scoped_ptr<MediaTracks> tracks) { 802 scoped_ptr<MediaTracks> tracks) {
802 // For MSE/chunk_demuxer case the media track updates are handled by 803 // For MSE/chunk_demuxer case the media track updates are handled by
803 // WebSourceBufferImpl. 804 // WebSourceBufferImpl.
804 DCHECK(demuxer_.get()); 805 DCHECK(demuxer_.get());
805 DCHECK(!chunk_demuxer_); 806 DCHECK(!chunk_demuxer_);
807
808 // Report the media track information to blink.
809 for (const auto& track : tracks->tracks()) {
810 if (track->type() == MediaTrack::Audio) {
811 auto track_id = client_->addAudioTrack(
812 blink::WebString::fromUTF8(track->id()),
813 blink::WebMediaPlayerClient::AudioTrackKindMain,
814 blink::WebString::fromUTF8(track->label()),
815 blink::WebString::fromUTF8(track->language()),
816 /*enabled*/ true);
817 (void)track_id;
818 } else if (track->type() == MediaTrack::Video) {
819 auto track_id = client_->addVideoTrack(
820 blink::WebString::fromUTF8(track->id()),
821 blink::WebMediaPlayerClient::VideoTrackKindMain,
822 blink::WebString::fromUTF8(track->label()),
823 blink::WebString::fromUTF8(track->language()),
824 /*selected*/ true);
825 (void)track_id;
826 } else {
827 // Text tracks are not supported through this code path yet.
828 NOTREACHED();
829 }
830 }
806 } 831 }
807 832
808 void WebMediaPlayerImpl::OnWaitingForDecryptionKey() { 833 void WebMediaPlayerImpl::OnWaitingForDecryptionKey() {
809 encrypted_client_->didBlockPlaybackWaitingForKey(); 834 encrypted_client_->didBlockPlaybackWaitingForKey();
810 835
811 // TODO(jrummell): didResumePlaybackBlockedForKey() should only be called 836 // TODO(jrummell): didResumePlaybackBlockedForKey() should only be called
812 // when a key has been successfully added (e.g. OnSessionKeysChange() with 837 // when a key has been successfully added (e.g. OnSessionKeysChange() with
813 // |has_additional_usable_key| = true). http://crbug.com/461903 838 // |has_additional_usable_key| = true). http://crbug.com/461903
814 encrypted_client_->didResumePlaybackBlockedForKey(); 839 encrypted_client_->didResumePlaybackBlockedForKey();
815 } 840 }
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
1202 Demuxer::EncryptedMediaInitDataCB encrypted_media_init_data_cb = 1227 Demuxer::EncryptedMediaInitDataCB encrypted_media_init_data_cb =
1203 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnEncryptedMediaInitData); 1228 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnEncryptedMediaInitData);
1204 1229
1205 // Figure out which demuxer to use. 1230 // Figure out which demuxer to use.
1206 if (load_type_ != LoadTypeMediaSource) { 1231 if (load_type_ != LoadTypeMediaSource) {
1207 DCHECK(!chunk_demuxer_); 1232 DCHECK(!chunk_demuxer_);
1208 DCHECK(data_source_); 1233 DCHECK(data_source_);
1209 1234
1210 #if !defined(MEDIA_DISABLE_FFMPEG) 1235 #if !defined(MEDIA_DISABLE_FFMPEG)
1211 Demuxer::MediaTracksUpdatedCB media_tracks_updated_cb = 1236 Demuxer::MediaTracksUpdatedCB media_tracks_updated_cb =
1212 base::Bind(&WebMediaPlayerImpl::OnFFmpegMediaTracksUpdated, 1237 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnFFmpegMediaTracksUpdated);
1213 base::Unretained(this));
1214 1238
1215 demuxer_.reset(new FFmpegDemuxer(media_task_runner_, data_source_.get(), 1239 demuxer_.reset(new FFmpegDemuxer(media_task_runner_, data_source_.get(),
1216 encrypted_media_init_data_cb, 1240 encrypted_media_init_data_cb,
1217 media_tracks_updated_cb, media_log_)); 1241 media_tracks_updated_cb, media_log_));
1218 #else 1242 #else
1219 OnPipelineError(PipelineStatus::DEMUXER_ERROR_COULD_NOT_OPEN); 1243 OnPipelineError(PipelineStatus::DEMUXER_ERROR_COULD_NOT_OPEN);
1220 return; 1244 return;
1221 #endif 1245 #endif
1222 } else { 1246 } else {
1223 DCHECK(!chunk_demuxer_); 1247 DCHECK(!chunk_demuxer_);
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
1428 << ", Video: " << stats.video_memory_usage << ", DataSource: " 1452 << ", Video: " << stats.video_memory_usage << ", DataSource: "
1429 << (data_source_ ? data_source_->GetMemoryUsage() : 0) 1453 << (data_source_ ? data_source_->GetMemoryUsage() : 0)
1430 << ", Demuxer: " << demuxer_memory_usage; 1454 << ", Demuxer: " << demuxer_memory_usage;
1431 1455
1432 const int64_t delta = current_memory_usage - last_reported_memory_usage_; 1456 const int64_t delta = current_memory_usage - last_reported_memory_usage_;
1433 last_reported_memory_usage_ = current_memory_usage; 1457 last_reported_memory_usage_ = current_memory_usage;
1434 adjust_allocated_memory_cb_.Run(delta); 1458 adjust_allocated_memory_cb_.Run(delta);
1435 } 1459 }
1436 1460
1437 } // namespace media 1461 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/media/avtrack/audio-track-properties.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698