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

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: Names. 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 == kInfiniteDuration())
182 event->params.SetString(key, "kInfiniteDuration");
183 else if (value == kNoTimestamp())
184 event->params.SetString(key, "kNoTimestamp");
185 else
186 event->params.SetDouble(key, value.InSecondsF());
187 }
188
178 scoped_ptr<FFmpegDemuxerStream> FFmpegDemuxerStream::Create( 189 scoped_ptr<FFmpegDemuxerStream> FFmpegDemuxerStream::Create(
179 FFmpegDemuxer* demuxer, 190 FFmpegDemuxer* demuxer,
180 AVStream* stream, 191 AVStream* stream,
181 const scoped_refptr<MediaLog>& media_log) { 192 const scoped_refptr<MediaLog>& media_log) {
182 if (!demuxer || !stream) 193 if (!demuxer || !stream)
183 return nullptr; 194 return nullptr;
184 195
185 scoped_ptr<FFmpegDemuxerStream> demuxer_stream; 196 scoped_ptr<FFmpegDemuxerStream> demuxer_stream;
186 scoped_ptr<AudioDecoderConfig> audio_config; 197 scoped_ptr<AudioDecoderConfig> audio_config;
187 scoped_ptr<VideoDecoderConfig> video_config; 198 scoped_ptr<VideoDecoderConfig> video_config;
(...skipping 1122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1310 // initializing. 1321 // initializing.
1311 host_->SetDuration(max_duration); 1322 host_->SetDuration(max_duration);
1312 duration_known_ = (max_duration != kInfiniteDuration()); 1323 duration_known_ = (max_duration != kInfiniteDuration());
1313 1324
1314 int64_t filesize_in_bytes = 0; 1325 int64_t filesize_in_bytes = 0;
1315 url_protocol_->GetSize(&filesize_in_bytes); 1326 url_protocol_->GetSize(&filesize_in_bytes);
1316 bitrate_ = CalculateBitrate(format_context, max_duration, filesize_in_bytes); 1327 bitrate_ = CalculateBitrate(format_context, max_duration, filesize_in_bytes);
1317 if (bitrate_ > 0) 1328 if (bitrate_ > 0)
1318 data_source_->SetBitrate(bitrate_); 1329 data_source_->SetBitrate(bitrate_);
1319 1330
1320 // Audio logging 1331 // Use a single MediaLogEvent to batch all parameter updates at once; this
1332 // prevents throttling of events due to the large number of updates here.
1333 scoped_ptr<MediaLogEvent> metadata_event =
1334 media_log_->CreateEvent(MediaLogEvent::PROPERTY_CHANGE);
1335
1336 // Audio logging.
1337 metadata_event->params.SetBoolean("found_audio_stream", !!audio_stream);
1321 if (audio_stream) { 1338 if (audio_stream) {
1322 AVCodecContext* audio_codec = audio_stream->codec; 1339 const AVCodecContext* audio_codec = audio_stream->codec;
1323 media_log_->SetBooleanProperty("found_audio_stream", true); 1340 metadata_event->params.SetString("audio_codec_name",
1324 1341 GetCodecName(audio_codec));
1325 SampleFormat sample_format = audio_config.sample_format(); 1342 metadata_event->params.SetInteger("audio_channels_count",
1326 std::string sample_name = SampleFormatToString(sample_format); 1343 audio_codec->channels);
1327 1344 metadata_event->params.SetString(
1328 media_log_->SetStringProperty("audio_sample_format", sample_name); 1345 "audio_sample_format",
1329 media_log_->SetStringProperty("audio_codec_name", 1346 SampleFormatToString(audio_config.sample_format()));
1330 GetCodecName(audio_codec)); 1347 metadata_event->params.SetInteger("audio_samples_per_second",
1331 media_log_->SetIntegerProperty("audio_channels_count", 1348 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 } 1349 }
1338 1350
1339 // Video logging 1351 // Video logging
1352 metadata_event->params.SetBoolean("found_video_stream", !!video_stream);
1340 if (video_stream) { 1353 if (video_stream) {
1341 AVCodecContext* video_codec = video_stream->codec; 1354 const AVCodecContext* video_codec = video_stream->codec;
1342 media_log_->SetBooleanProperty("found_video_stream", true); 1355 metadata_event->params.SetString("video_codec_name",
1343 media_log_->SetStringProperty("video_codec_name", 1356 GetCodecName(video_codec));
1344 GetCodecName(video_codec)); 1357 metadata_event->params.SetInteger("width", video_codec->width);
1345 media_log_->SetIntegerProperty("width", video_codec->width); 1358 metadata_event->params.SetInteger("height", video_codec->height);
1346 media_log_->SetIntegerProperty("height", video_codec->height); 1359 metadata_event->params.SetInteger("coded_width", video_codec->coded_width);
1347 media_log_->SetIntegerProperty("coded_width", video_codec->coded_width); 1360 metadata_event->params.SetInteger("coded_height",
1348 media_log_->SetIntegerProperty("coded_height", video_codec->coded_height); 1361 video_codec->coded_height);
1349 media_log_->SetStringProperty( 1362 metadata_event->params.SetString(
1350 "time_base", base::StringPrintf("%d/%d", video_codec->time_base.num, 1363 "time_base", base::StringPrintf("%d/%d", video_codec->time_base.num,
1351 video_codec->time_base.den)); 1364 video_codec->time_base.den));
1352 media_log_->SetStringProperty( 1365 metadata_event->params.SetString(
1353 "video_format", VideoPixelFormatToString(video_config.format())); 1366 "video_format", VideoPixelFormatToString(video_config.format()));
1354 media_log_->SetBooleanProperty("video_is_encrypted", 1367 metadata_event->params.SetBoolean("video_is_encrypted",
1355 video_config.is_encrypted()); 1368 video_config.is_encrypted());
1356 } else {
1357 media_log_->SetBooleanProperty("found_video_stream", false);
1358 } 1369 }
1359 1370
1360 media_log_->SetTimeProperty("max_duration", max_duration); 1371 SetTimeProperty(metadata_event.get(), "max_duration", max_duration);
1361 media_log_->SetTimeProperty("start_time", start_time_); 1372 SetTimeProperty(metadata_event.get(), "start_time", start_time_);
1362 media_log_->SetIntegerProperty("bitrate", bitrate_); 1373 metadata_event->params.SetInteger("bitrate", bitrate_);
1374 media_log_->AddEvent(std::move(metadata_event));
1363 1375
1364 media_tracks_updated_cb_.Run(std::move(media_tracks)); 1376 media_tracks_updated_cb_.Run(std::move(media_tracks));
1365 1377
1366 status_cb.Run(PIPELINE_OK); 1378 status_cb.Run(PIPELINE_OK);
1367 } 1379 }
1368 1380
1369 void FFmpegDemuxer::OnSeekFrameDone(const PipelineStatusCB& cb, int result) { 1381 void FFmpegDemuxer::OnSeekFrameDone(const PipelineStatusCB& cb, int result) {
1370 DCHECK(task_runner_->BelongsToCurrentThread()); 1382 DCHECK(task_runner_->BelongsToCurrentThread());
1371 CHECK(pending_seek_); 1383 CHECK(pending_seek_);
1372 pending_seek_ = false; 1384 pending_seek_ = false;
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
1538 1550
1539 void FFmpegDemuxer::SetLiveness(DemuxerStream::Liveness liveness) { 1551 void FFmpegDemuxer::SetLiveness(DemuxerStream::Liveness liveness) {
1540 DCHECK(task_runner_->BelongsToCurrentThread()); 1552 DCHECK(task_runner_->BelongsToCurrentThread());
1541 for (const auto& stream : streams_) { // |stream| is a ref to a pointer. 1553 for (const auto& stream : streams_) { // |stream| is a ref to a pointer.
1542 if (stream) 1554 if (stream)
1543 stream->SetLiveness(liveness); 1555 stream->SetLiveness(liveness);
1544 } 1556 }
1545 } 1557 }
1546 1558
1547 } // namespace media 1559 } // 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