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

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

Issue 1800353002: Reduce MediaLog spam and add a note about unsupported statuses. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove dead setters. 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 | « media/base/media_log.cc ('k') | no next file » | 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 <utility> 8 #include <utility>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 168
169 static const char* GetCodecName(const AVCodecContext* context) { 169 static const char* GetCodecName(const AVCodecContext* context) {
170 if (context->codec_descriptor) 170 if (context->codec_descriptor)
171 return context->codec_descriptor->name; 171 return context->codec_descriptor->name;
172 const AVCodecDescriptor* codec_descriptor = 172 const AVCodecDescriptor* codec_descriptor =
173 avcodec_descriptor_get(context->codec_id); 173 avcodec_descriptor_get(context->codec_id);
174 // If the codec name can't be determined, return none for tracking. 174 // If the codec name can't be determined, return none for tracking.
175 return codec_descriptor ? codec_descriptor->name : kCodecNone; 175 return codec_descriptor ? codec_descriptor->name : kCodecNone;
176 } 176 }
177 177
178 static void SetTimeProperty(MediaLogEvent* event,
179 const std::string& key,
180 base::TimeDelta value) {
181 if (value.is_max())
182 event->params.SetString(key, "unknown");
183 else
184 event->params.SetDouble(key, value.InSecondsF());
185 }
xhwang 2016/03/18 17:31:35 OOC, when will we set the max TimeDelta? We do us
DaleCurtis 2016/03/18 17:36:49 kInfiniteDuration() return TimeDelta::Max(). We co
xhwang 2016/03/18 17:40:09 Yeah, that makes sense for the duration, but for t
DaleCurtis 2016/03/18 18:01:30 We DCHECK() that it doesn't happen in a lot of cas
186
178 scoped_ptr<FFmpegDemuxerStream> FFmpegDemuxerStream::Create( 187 scoped_ptr<FFmpegDemuxerStream> FFmpegDemuxerStream::Create(
179 FFmpegDemuxer* demuxer, 188 FFmpegDemuxer* demuxer,
180 AVStream* stream, 189 AVStream* stream,
181 const scoped_refptr<MediaLog>& media_log) { 190 const scoped_refptr<MediaLog>& media_log) {
182 if (!demuxer || !stream) 191 if (!demuxer || !stream)
183 return nullptr; 192 return nullptr;
184 193
185 scoped_ptr<FFmpegDemuxerStream> demuxer_stream; 194 scoped_ptr<FFmpegDemuxerStream> demuxer_stream;
186 scoped_ptr<AudioDecoderConfig> audio_config; 195 scoped_ptr<AudioDecoderConfig> audio_config;
187 scoped_ptr<VideoDecoderConfig> video_config; 196 scoped_ptr<VideoDecoderConfig> video_config;
(...skipping 1122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1310 // initializing. 1319 // initializing.
1311 host_->SetDuration(max_duration); 1320 host_->SetDuration(max_duration);
1312 duration_known_ = (max_duration != kInfiniteDuration()); 1321 duration_known_ = (max_duration != kInfiniteDuration());
1313 1322
1314 int64_t filesize_in_bytes = 0; 1323 int64_t filesize_in_bytes = 0;
1315 url_protocol_->GetSize(&filesize_in_bytes); 1324 url_protocol_->GetSize(&filesize_in_bytes);
1316 bitrate_ = CalculateBitrate(format_context, max_duration, filesize_in_bytes); 1325 bitrate_ = CalculateBitrate(format_context, max_duration, filesize_in_bytes);
1317 if (bitrate_ > 0) 1326 if (bitrate_ > 0)
1318 data_source_->SetBitrate(bitrate_); 1327 data_source_->SetBitrate(bitrate_);
1319 1328
1320 // Audio logging 1329 // Use a single MediaLogEvent to batch all parameter updates at once; this
1330 // prevents throttling of events due to the large number of updates here.
1331 scoped_ptr<MediaLogEvent> metadata_event =
1332 media_log_->CreateEvent(MediaLogEvent::PROPERTY_CHANGE);
1333
1334 // Audio logging.
1335 metadata_event->params.SetBoolean("found_audio_stream", !!audio_stream);
1321 if (audio_stream) { 1336 if (audio_stream) {
1322 AVCodecContext* audio_codec = audio_stream->codec; 1337 const AVCodecContext* audio_codec = audio_stream->codec;
1323 media_log_->SetBooleanProperty("found_audio_stream", true); 1338 metadata_event->params.SetString("audio_codec_name",
1324 1339 GetCodecName(audio_codec));
1325 SampleFormat sample_format = audio_config.sample_format(); 1340 metadata_event->params.SetInteger("audio_channels_count",
1326 std::string sample_name = SampleFormatToString(sample_format); 1341 audio_codec->channels);
1327 1342 metadata_event->params.SetString(
1328 media_log_->SetStringProperty("audio_sample_format", sample_name); 1343 "audio_sample_format",
1329 media_log_->SetStringProperty("audio_codec_name", 1344 SampleFormatToString(audio_config.sample_format()));
1330 GetCodecName(audio_codec)); 1345 metadata_event->params.SetInteger("audio_samples_per_second",
1331 media_log_->SetIntegerProperty("audio_channels_count", 1346 audio_config.samples_per_second());
1332 audio_codec->channels);
1333 media_log_->SetIntegerProperty("audio_samples_per_second",
1334 audio_config.samples_per_second());
1335 } else {
1336 media_log_->SetBooleanProperty("found_audio_stream", false);
1337 } 1347 }
1338 1348
1339 // Video logging 1349 // Video logging
1350 metadata_event->params.SetBoolean("found_video_stream", !!video_stream);
1340 if (video_stream) { 1351 if (video_stream) {
1341 AVCodecContext* video_codec = video_stream->codec; 1352 const AVCodecContext* video_codec = video_stream->codec;
1342 media_log_->SetBooleanProperty("found_video_stream", true); 1353 metadata_event->params.SetString("video_codec_name",
1343 media_log_->SetStringProperty("video_codec_name", 1354 GetCodecName(video_codec));
1344 GetCodecName(video_codec)); 1355 metadata_event->params.SetInteger("width", video_codec->width);
1345 media_log_->SetIntegerProperty("width", video_codec->width); 1356 metadata_event->params.SetInteger("height", video_codec->height);
1346 media_log_->SetIntegerProperty("height", video_codec->height); 1357 metadata_event->params.SetInteger("coded_width", video_codec->coded_width);
1347 media_log_->SetIntegerProperty("coded_width", video_codec->coded_width); 1358 metadata_event->params.SetInteger("coded_height",
1348 media_log_->SetIntegerProperty("coded_height", video_codec->coded_height); 1359 video_codec->coded_height);
1349 media_log_->SetStringProperty( 1360 metadata_event->params.SetString(
1350 "time_base", base::StringPrintf("%d/%d", video_codec->time_base.num, 1361 "time_base", base::StringPrintf("%d/%d", video_codec->time_base.num,
1351 video_codec->time_base.den)); 1362 video_codec->time_base.den));
1352 media_log_->SetStringProperty( 1363 metadata_event->params.SetString(
1353 "video_format", VideoPixelFormatToString(video_config.format())); 1364 "video_format", VideoPixelFormatToString(video_config.format()));
1354 media_log_->SetBooleanProperty("video_is_encrypted", 1365 metadata_event->params.SetBoolean("video_is_encrypted",
1355 video_config.is_encrypted()); 1366 video_config.is_encrypted());
1356 } else {
1357 media_log_->SetBooleanProperty("found_video_stream", false);
1358 } 1367 }
1359 1368
1360 media_log_->SetTimeProperty("max_duration", max_duration); 1369 SetTimeProperty(metadata_event.get(), "max_duration", max_duration);
1361 media_log_->SetTimeProperty("start_time", start_time_); 1370 SetTimeProperty(metadata_event.get(), "start_time", start_time_);
1362 media_log_->SetIntegerProperty("bitrate", bitrate_); 1371 metadata_event->params.SetInteger("bitrate", bitrate_);
1372 media_log_->AddEvent(std::move(metadata_event));
1363 1373
1364 media_tracks_updated_cb_.Run(std::move(media_tracks)); 1374 media_tracks_updated_cb_.Run(std::move(media_tracks));
1365 1375
1366 status_cb.Run(PIPELINE_OK); 1376 status_cb.Run(PIPELINE_OK);
1367 } 1377 }
1368 1378
1369 void FFmpegDemuxer::OnSeekFrameDone(const PipelineStatusCB& cb, int result) { 1379 void FFmpegDemuxer::OnSeekFrameDone(const PipelineStatusCB& cb, int result) {
1370 DCHECK(task_runner_->BelongsToCurrentThread()); 1380 DCHECK(task_runner_->BelongsToCurrentThread());
1371 CHECK(pending_seek_); 1381 CHECK(pending_seek_);
1372 pending_seek_ = false; 1382 pending_seek_ = false;
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
1538 1548
1539 void FFmpegDemuxer::SetLiveness(DemuxerStream::Liveness liveness) { 1549 void FFmpegDemuxer::SetLiveness(DemuxerStream::Liveness liveness) {
1540 DCHECK(task_runner_->BelongsToCurrentThread()); 1550 DCHECK(task_runner_->BelongsToCurrentThread());
1541 for (const auto& stream : streams_) { // |stream| is a ref to a pointer. 1551 for (const auto& stream : streams_) { // |stream| is a ref to a pointer.
1542 if (stream) 1552 if (stream)
1543 stream->SetLiveness(liveness); 1553 stream->SetLiveness(liveness);
1544 } 1554 }
1545 } 1555 }
1546 1556
1547 } // namespace media 1557 } // namespace media
OLDNEW
« no previous file with comments | « media/base/media_log.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698