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

Side by Side Diff: content/renderer/media/android/media_source_delegate.cc

Issue 1047313002: media-internals: Simplify the code path for creating a media log entry (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@MEDIA_LOG_INFO_ERROR_DEBUG
Patch Set: Fix compile on Android Created 5 years, 8 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 | media/base/media_log.h » ('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 "content/renderer/media/android/media_source_delegate.h" 5 #include "content/renderer/media/android/media_source_delegate.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 22 matching lines...) Expand all
33 // The size of the access unit to transfer in an IPC in case of MediaSource. 33 // The size of the access unit to transfer in an IPC in case of MediaSource.
34 // 4: approximately 64ms of content in 60 fps movies. 34 // 4: approximately 64ms of content in 60 fps movies.
35 const size_t kAccessUnitSizeForMediaSource = 4; 35 const size_t kAccessUnitSizeForMediaSource = 4;
36 36
37 const uint8 kVorbisPadding[] = { 0xff, 0xff, 0xff, 0xff }; 37 const uint8 kVorbisPadding[] = { 0xff, 0xff, 0xff, 0xff };
38 38
39 } // namespace 39 } // namespace
40 40
41 namespace content { 41 namespace content {
42 42
43 static void AddLogEntry(const scoped_refptr<media::MediaLog>& media_log,
44 media::MediaLog::MediaLogLevel level,
45 const std::string& message) {
46 media_log->AddEvent(media_log->CreateLogEvent(level, message));
47 }
48
49 MediaSourceDelegate::MediaSourceDelegate( 43 MediaSourceDelegate::MediaSourceDelegate(
50 RendererDemuxerAndroid* demuxer_client, 44 RendererDemuxerAndroid* demuxer_client,
51 int demuxer_client_id, 45 int demuxer_client_id,
52 const scoped_refptr<base::SingleThreadTaskRunner>& media_task_runner, 46 const scoped_refptr<base::SingleThreadTaskRunner>& media_task_runner,
53 const scoped_refptr<media::MediaLog> media_log) 47 const scoped_refptr<media::MediaLog> media_log)
54 : demuxer_client_(demuxer_client), 48 : demuxer_client_(demuxer_client),
55 demuxer_client_id_(demuxer_client_id), 49 demuxer_client_id_(demuxer_client_id),
56 media_log_(media_log), 50 media_log_(media_log),
57 is_demuxer_ready_(false), 51 is_demuxer_ready_(false),
58 audio_stream_(NULL), 52 audio_stream_(NULL),
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 duration_change_cb_ = duration_change_cb; 158 duration_change_cb_ = duration_change_cb;
165 waiting_for_decryption_key_cb_ = 159 waiting_for_decryption_key_cb_ =
166 media::BindToCurrentLoop(waiting_for_decryption_key_cb); 160 media::BindToCurrentLoop(waiting_for_decryption_key_cb);
167 access_unit_size_ = kAccessUnitSizeForMediaSource; 161 access_unit_size_ = kAccessUnitSizeForMediaSource;
168 162
169 chunk_demuxer_.reset(new media::ChunkDemuxer( 163 chunk_demuxer_.reset(new media::ChunkDemuxer(
170 media::BindToCurrentLoop( 164 media::BindToCurrentLoop(
171 base::Bind(&MediaSourceDelegate::OnDemuxerOpened, main_weak_this_)), 165 base::Bind(&MediaSourceDelegate::OnDemuxerOpened, main_weak_this_)),
172 media::BindToCurrentLoop(base::Bind( 166 media::BindToCurrentLoop(base::Bind(
173 &MediaSourceDelegate::OnEncryptedMediaInitData, main_weak_this_)), 167 &MediaSourceDelegate::OnEncryptedMediaInitData, main_weak_this_)),
174 base::Bind(&AddLogEntry, media_log_), media_log_, false)); 168 base::Bind(&media::MediaLog::AddLogEvent, media_log_), media_log_,
169 false));
175 170
176 // |this| will be retained until StopDemuxer() is posted, so Unretained() is 171 // |this| will be retained until StopDemuxer() is posted, so Unretained() is
177 // safe here. 172 // safe here.
178 media_task_runner_->PostTask(FROM_HERE, 173 media_task_runner_->PostTask(FROM_HERE,
179 base::Bind(&MediaSourceDelegate::InitializeDemuxer, 174 base::Bind(&MediaSourceDelegate::InitializeDemuxer,
180 base::Unretained(this))); 175 base::Unretained(this)));
181 } 176 }
182 177
183 void MediaSourceDelegate::InitializeDemuxer() { 178 void MediaSourceDelegate::InitializeDemuxer() {
184 DCHECK(media_task_runner_->BelongsToCurrentThread()); 179 DCHECK(media_task_runner_->BelongsToCurrentThread());
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 658
664 return media::ConvertSecondsToTimestamp(duration); 659 return media::ConvertSecondsToTimestamp(duration);
665 } 660 }
666 661
667 void MediaSourceDelegate::OnDemuxerOpened() { 662 void MediaSourceDelegate::OnDemuxerOpened() {
668 DCHECK(main_task_runner_->BelongsToCurrentThread()); 663 DCHECK(main_task_runner_->BelongsToCurrentThread());
669 if (media_source_opened_cb_.is_null()) 664 if (media_source_opened_cb_.is_null())
670 return; 665 return;
671 666
672 media_source_opened_cb_.Run(new media::WebMediaSourceImpl( 667 media_source_opened_cb_.Run(new media::WebMediaSourceImpl(
673 chunk_demuxer_.get(), base::Bind(&AddLogEntry, media_log_))); 668 chunk_demuxer_.get(),
669 base::Bind(&media::MediaLog::AddLogEvent, media_log_)));
674 } 670 }
675 671
676 void MediaSourceDelegate::OnEncryptedMediaInitData( 672 void MediaSourceDelegate::OnEncryptedMediaInitData(
677 const std::string& init_data_type, 673 const std::string& init_data_type,
678 const std::vector<uint8>& init_data) { 674 const std::vector<uint8>& init_data) {
679 DCHECK(main_task_runner_->BelongsToCurrentThread()); 675 DCHECK(main_task_runner_->BelongsToCurrentThread());
680 if (encrypted_media_init_data_cb_.is_null()) 676 if (encrypted_media_init_data_cb_.is_null())
681 return; 677 return;
682 678
683 encrypted_media_init_data_cb_.Run(init_data_type, init_data); 679 encrypted_media_init_data_cb_.Run(init_data_type, init_data);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 configs->video_size = config.natural_size(); 754 configs->video_size = config.natural_size();
759 configs->is_video_encrypted = config.is_encrypted(); 755 configs->is_video_encrypted = config.is_encrypted();
760 configs->video_extra_data = std::vector<uint8>( 756 configs->video_extra_data = std::vector<uint8>(
761 config.extra_data(), config.extra_data() + config.extra_data_size()); 757 config.extra_data(), config.extra_data() + config.extra_data_size());
762 return true; 758 return true;
763 } 759 }
764 return false; 760 return false;
765 } 761 }
766 762
767 } // namespace content 763 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | media/base/media_log.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698