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

Side by Side Diff: media/cast/audio_sender/audio_sender.cc

Issue 163553006: Cast: Refactoring Cast API's (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 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 | Annotate | Revision Log
« no previous file with comments | « media/cast/audio_sender/audio_sender.h ('k') | media/cast/cast_config.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 "media/cast/audio_sender/audio_sender.h" 5 #include "media/cast/audio_sender/audio_sender.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "media/cast/audio_sender/audio_encoder.h" 10 #include "media/cast/audio_sender/audio_encoder.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 transport_sender_, 106 transport_sender_,
107 NULL, // paced sender. 107 NULL, // paced sender.
108 rtp_audio_sender_statistics_.get(), 108 rtp_audio_sender_statistics_.get(),
109 NULL, 109 NULL,
110 audio_config.rtcp_mode, 110 audio_config.rtcp_mode,
111 base::TimeDelta::FromMilliseconds(audio_config.rtcp_interval), 111 base::TimeDelta::FromMilliseconds(audio_config.rtcp_interval),
112 audio_config.sender_ssrc, 112 audio_config.sender_ssrc,
113 audio_config.incoming_feedback_ssrc, 113 audio_config.incoming_feedback_ssrc,
114 audio_config.rtcp_c_name), 114 audio_config.rtcp_c_name),
115 timers_initialized_(false), 115 timers_initialized_(false),
116 initialization_status_(STATUS_INITIALIZED), 116 cast_initialization_cb_(STATUS_AUDIO_UNINITIALIZED),
117 weak_factory_(this) { 117 weak_factory_(this) {
118 rtcp_.SetCastReceiverEventHistorySize(kReceiverRtcpEventHistorySize); 118 rtcp_.SetCastReceiverEventHistorySize(kReceiverRtcpEventHistorySize);
119 if (!audio_config.use_external_encoder) { 119 if (!audio_config.use_external_encoder) {
120 audio_encoder_ = 120 audio_encoder_ =
121 new AudioEncoder(cast_environment, 121 new AudioEncoder(cast_environment,
122 audio_config, 122 audio_config,
123 base::Bind(&AudioSender::SendEncodedAudioFrame, 123 base::Bind(&AudioSender::SendEncodedAudioFrame,
124 weak_factory_.GetWeakPtr())); 124 weak_factory_.GetWeakPtr()));
125 initialization_status_ = audio_encoder_->InitializationResult(); 125 cast_initialization_cb_ = audio_encoder_->InitializationResult();
126 } 126 }
127 } 127 }
128 128
129 AudioSender::~AudioSender() {} 129 AudioSender::~AudioSender() {}
130 130
131 void AudioSender::InitializeTimers() { 131 void AudioSender::InitializeTimers() {
132 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 132 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
133 if (!timers_initialized_) { 133 if (!timers_initialized_) {
134 timers_initialized_ = true; 134 timers_initialized_ = true;
135 ScheduleNextRtcpReport(); 135 ScheduleNextRtcpReport();
136 } 136 }
137 } 137 }
138 138
139 void AudioSender::InsertAudio(const AudioBus* audio_bus, 139 void AudioSender::InsertAudio(const AudioBus* audio_bus,
140 const base::TimeTicks& recorded_time, 140 const base::TimeTicks& recorded_time,
141 const base::Closure& done_callback) { 141 const base::Closure& done_callback) {
142 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 142 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
143 DCHECK(audio_encoder_.get()) << "Invalid internal state"; 143 DCHECK(audio_encoder_.get()) << "Invalid internal state";
144
145 audio_encoder_->InsertAudio(audio_bus, recorded_time, done_callback); 144 audio_encoder_->InsertAudio(audio_bus, recorded_time, done_callback);
146 } 145 }
147 146
148 void AudioSender::SendEncodedAudioFrame( 147 void AudioSender::SendEncodedAudioFrame(
149 scoped_ptr<transport::EncodedAudioFrame> audio_frame, 148 scoped_ptr<transport::EncodedAudioFrame> audio_frame,
150 const base::TimeTicks& recorded_time) { 149 const base::TimeTicks& recorded_time) {
151 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 150 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
152 InitializeTimers(); 151 InitializeTimers();
153 cast_environment_->PostTask( 152 cast_environment_->PostTask(
154 CastEnvironment::TRANSPORT, 153 CastEnvironment::TRANSPORT,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 } 206 }
208 207
209 void AudioSender::ResendPacketsOnTransportThread( 208 void AudioSender::ResendPacketsOnTransportThread(
210 const transport::MissingFramesAndPacketsMap& missing_packets) { 209 const transport::MissingFramesAndPacketsMap& missing_packets) {
211 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::TRANSPORT)); 210 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::TRANSPORT));
212 transport_sender_->ResendPackets(true, missing_packets); 211 transport_sender_->ResendPackets(true, missing_packets);
213 } 212 }
214 213
215 } // namespace cast 214 } // namespace cast
216 } // namespace media 215 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/audio_sender/audio_sender.h ('k') | media/cast/cast_config.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698