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

Side by Side Diff: media/filters/ffmpeg_demuxer.cc

Issue 2272293002: Introducing DemuxerHost::OnMetadata. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 3 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 | « media/filters/chunk_demuxer.cc ('k') | third_party/WebKit/LayoutTests/TestExpectations » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/filters/ffmpeg_demuxer.h" 5 #include "media/filters/ffmpeg_demuxer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 1422 matching lines...) Expand 10 before | Expand all | Expand 10 after
1433 // initializing. 1433 // initializing.
1434 host_->SetDuration(max_duration); 1434 host_->SetDuration(max_duration);
1435 duration_known_ = (max_duration != kInfiniteDuration); 1435 duration_known_ = (max_duration != kInfiniteDuration);
1436 1436
1437 int64_t filesize_in_bytes = 0; 1437 int64_t filesize_in_bytes = 0;
1438 url_protocol_->GetSize(&filesize_in_bytes); 1438 url_protocol_->GetSize(&filesize_in_bytes);
1439 bitrate_ = CalculateBitrate(format_context, max_duration, filesize_in_bytes); 1439 bitrate_ = CalculateBitrate(format_context, max_duration, filesize_in_bytes);
1440 if (bitrate_ > 0) 1440 if (bitrate_ > 0)
1441 data_source_->SetBitrate(bitrate_); 1441 data_source_->SetBitrate(bitrate_);
1442 1442
1443 PipelineMetadata metadata;
1443 // Use a single MediaLogEvent to batch all parameter updates at once; this 1444 // Use a single MediaLogEvent to batch all parameter updates at once; this
1444 // prevents throttling of events due to the large number of updates here. 1445 // prevents throttling of events due to the large number of updates here.
1445 std::unique_ptr<MediaLogEvent> metadata_event = 1446 std::unique_ptr<MediaLogEvent> metadata_event =
1446 media_log_->CreateEvent(MediaLogEvent::PROPERTY_CHANGE); 1447 media_log_->CreateEvent(MediaLogEvent::PROPERTY_CHANGE);
1447 1448
1448 // Audio logging. 1449 // Audio logging.
1449 metadata_event->params.SetBoolean("found_audio_stream", !!audio_stream); 1450 metadata_event->params.SetBoolean("found_audio_stream", !!audio_stream);
1450 if (audio_stream) { 1451 if (audio_stream) {
1451 const AVCodecContext* audio_codec = audio_stream->codec; 1452 const AVCodecContext* audio_codec = audio_stream->codec;
1453 metadata.has_audio = true;
1452 metadata_event->params.SetString("audio_codec_name", 1454 metadata_event->params.SetString("audio_codec_name",
1453 GetCodecName(audio_codec)); 1455 GetCodecName(audio_codec));
1454 metadata_event->params.SetInteger("audio_channels_count", 1456 metadata_event->params.SetInteger("audio_channels_count",
1455 audio_codec->channels); 1457 audio_codec->channels);
1456 metadata_event->params.SetString( 1458 metadata_event->params.SetString(
1457 "audio_sample_format", 1459 "audio_sample_format",
1458 SampleFormatToString(audio_config.sample_format())); 1460 SampleFormatToString(audio_config.sample_format()));
1459 metadata_event->params.SetInteger("audio_samples_per_second", 1461 metadata_event->params.SetInteger("audio_samples_per_second",
1460 audio_config.samples_per_second()); 1462 audio_config.samples_per_second());
1461 } 1463 }
1462 1464
1463 // Video logging 1465 // Video logging
1464 metadata_event->params.SetBoolean("found_video_stream", !!video_stream); 1466 metadata_event->params.SetBoolean("found_video_stream", !!video_stream);
1465 if (video_stream) { 1467 if (video_stream) {
1466 const AVCodecContext* video_codec = video_stream->codec; 1468 const AVCodecContext* video_codec = video_stream->codec;
1469 metadata.has_video = true;
1470 metadata.natural_size = video_->video_decoder_config().natural_size();
1471 metadata.video_rotation = video_->video_rotation();
1467 metadata_event->params.SetString("video_codec_name", 1472 metadata_event->params.SetString("video_codec_name",
1468 GetCodecName(video_codec)); 1473 GetCodecName(video_codec));
1469 metadata_event->params.SetInteger("width", video_codec->width); 1474 metadata_event->params.SetInteger("width", video_codec->width);
1470 metadata_event->params.SetInteger("height", video_codec->height); 1475 metadata_event->params.SetInteger("height", video_codec->height);
1471 metadata_event->params.SetInteger("coded_width", video_codec->coded_width); 1476 metadata_event->params.SetInteger("coded_width", video_codec->coded_width);
1472 metadata_event->params.SetInteger("coded_height", 1477 metadata_event->params.SetInteger("coded_height",
1473 video_codec->coded_height); 1478 video_codec->coded_height);
1474 metadata_event->params.SetString( 1479 metadata_event->params.SetString(
1475 "time_base", base::StringPrintf("%d/%d", video_codec->time_base.num, 1480 "time_base", base::StringPrintf("%d/%d", video_codec->time_base.num,
1476 video_codec->time_base.den)); 1481 video_codec->time_base.den));
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1697 1702
1698 void FFmpegDemuxer::SetLiveness(DemuxerStream::Liveness liveness) { 1703 void FFmpegDemuxer::SetLiveness(DemuxerStream::Liveness liveness) {
1699 DCHECK(task_runner_->BelongsToCurrentThread()); 1704 DCHECK(task_runner_->BelongsToCurrentThread());
1700 for (auto* stream : streams_) { 1705 for (auto* stream : streams_) {
1701 if (stream) 1706 if (stream)
1702 stream->SetLiveness(liveness); 1707 stream->SetLiveness(liveness);
1703 } 1708 }
1704 } 1709 }
1705 1710
1706 } // namespace media 1711 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/chunk_demuxer.cc ('k') | third_party/WebKit/LayoutTests/TestExpectations » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698