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

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

Issue 126843003: Revert of Cast:Adding cast_transport_config and cleaning up (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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
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 "crypto/encryptor.h" 10 #include "crypto/encryptor.h"
11 #include "crypto/symmetric_key.h" 11 #include "crypto/symmetric_key.h"
12 #include "media/cast/audio_sender/audio_encoder.h" 12 #include "media/cast/audio_sender/audio_encoder.h"
13 #include "media/cast/cast_environment.h"
13 #include "media/cast/rtcp/rtcp.h" 14 #include "media/cast/rtcp/rtcp.h"
14 #include "media/cast/transport/rtp_sender/rtp_sender.h" 15 #include "media/cast/transport/rtp_sender/rtp_sender.h"
15 16
16 namespace media { 17 namespace media {
17 namespace cast { 18 namespace cast {
18 19
19 const int64 kMinSchedulingDelayMs = 1; 20 const int64 kMinSchedulingDelayMs = 1;
20 21
21 class LocalRtcpAudioSenderFeedback : public RtcpSenderFeedback { 22 class LocalRtcpAudioSenderFeedback : public RtcpSenderFeedback {
22 public: 23 public:
(...skipping 27 matching lines...) Expand all
50 51
51 private: 52 private:
52 transport::RtpSender* rtp_sender_; 53 transport::RtpSender* rtp_sender_;
53 }; 54 };
54 55
55 AudioSender::AudioSender( 56 AudioSender::AudioSender(
56 scoped_refptr<CastEnvironment> cast_environment, 57 scoped_refptr<CastEnvironment> cast_environment,
57 const AudioSenderConfig& audio_config, 58 const AudioSenderConfig& audio_config,
58 transport::PacedPacketSender* const paced_packet_sender) 59 transport::PacedPacketSender* const paced_packet_sender)
59 : cast_environment_(cast_environment), 60 : cast_environment_(cast_environment),
60 rtp_sender_(cast_environment->Clock(), &audio_config, NULL, 61 rtp_sender_(cast_environment, &audio_config, NULL,
61 paced_packet_sender), 62 paced_packet_sender),
62 rtcp_feedback_(new LocalRtcpAudioSenderFeedback(this)), 63 rtcp_feedback_(new LocalRtcpAudioSenderFeedback(this)),
63 rtp_audio_sender_statistics_( 64 rtp_audio_sender_statistics_(
64 new LocalRtpSenderStatistics(&rtp_sender_)), 65 new LocalRtpSenderStatistics(&rtp_sender_)),
65 rtcp_(cast_environment, 66 rtcp_(cast_environment,
66 rtcp_feedback_.get(), 67 rtcp_feedback_.get(),
67 paced_packet_sender, 68 paced_packet_sender,
68 rtp_audio_sender_statistics_.get(), 69 rtp_audio_sender_statistics_.get(),
69 NULL, 70 NULL,
70 audio_config.rtcp_mode, 71 audio_config.rtcp_mode,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 112 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
112 DCHECK(audio_encoder_.get()) << "Invalid internal state"; 113 DCHECK(audio_encoder_.get()) << "Invalid internal state";
113 // TODO(mikhal): Resolve calculation of the audio rtp_timestamp for logging. 114 // TODO(mikhal): Resolve calculation of the audio rtp_timestamp for logging.
114 // This is a tmp solution to allow the code to build. 115 // This is a tmp solution to allow the code to build.
115 base::TimeTicks now = cast_environment_->Clock()->NowTicks(); 116 base::TimeTicks now = cast_environment_->Clock()->NowTicks();
116 cast_environment_->Logging()->InsertFrameEvent(now, kAudioFrameReceived, 117 cast_environment_->Logging()->InsertFrameEvent(now, kAudioFrameReceived,
117 GetVideoRtpTimestamp(recorded_time), kFrameIdUnknown); 118 GetVideoRtpTimestamp(recorded_time), kFrameIdUnknown);
118 audio_encoder_->InsertAudio(audio_bus, recorded_time, done_callback); 119 audio_encoder_->InsertAudio(audio_bus, recorded_time, done_callback);
119 } 120 }
120 121
121 void AudioSender::InsertCodedAudioFrame( 122 void AudioSender::InsertCodedAudioFrame(const EncodedAudioFrame* audio_frame,
122 const transport::EncodedAudioFrame* audio_frame, 123 const base::TimeTicks& recorded_time,
123 const base::TimeTicks& recorded_time, 124 const base::Closure callback) {
124 const base::Closure callback) {
125 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 125 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
126 DCHECK(audio_encoder_.get() == NULL) << "Invalid internal state"; 126 DCHECK(audio_encoder_.get() == NULL) << "Invalid internal state";
127 127
128 base::TimeTicks now = cast_environment_->Clock()->NowTicks(); 128 base::TimeTicks now = cast_environment_->Clock()->NowTicks();
129 cast_environment_->Logging()->InsertFrameEvent(now, kAudioFrameReceived, 129 cast_environment_->Logging()->InsertFrameEvent(now, kAudioFrameReceived,
130 GetVideoRtpTimestamp(recorded_time), kFrameIdUnknown); 130 GetVideoRtpTimestamp(recorded_time), kFrameIdUnknown);
131 131
132 if (encryptor_) { 132 if (encryptor_) {
133 transport::EncodedAudioFrame encrypted_frame; 133 EncodedAudioFrame encrypted_frame;
134 if (!EncryptAudioFrame(*audio_frame, &encrypted_frame)) { 134 if (!EncryptAudioFrame(*audio_frame, &encrypted_frame)) {
135 // Logging already done. 135 // Logging already done.
136 return; 136 return;
137 } 137 }
138 rtp_sender_.IncomingEncodedAudioFrame(&encrypted_frame, recorded_time); 138 rtp_sender_.IncomingEncodedAudioFrame(&encrypted_frame, recorded_time);
139 } else { 139 } else {
140 rtp_sender_.IncomingEncodedAudioFrame(audio_frame, recorded_time); 140 rtp_sender_.IncomingEncodedAudioFrame(audio_frame, recorded_time);
141 } 141 }
142 callback.Run(); 142 callback.Run();
143 } 143 }
144 144
145 void AudioSender::SendEncodedAudioFrame( 145 void AudioSender::SendEncodedAudioFrame(
146 scoped_ptr<transport::EncodedAudioFrame> audio_frame, 146 scoped_ptr<EncodedAudioFrame> audio_frame,
147 const base::TimeTicks& recorded_time) { 147 const base::TimeTicks& recorded_time) {
148 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 148 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
149 InitializeTimers(); 149 InitializeTimers();
150 if (encryptor_) { 150 if (encryptor_) {
151 transport::EncodedAudioFrame encrypted_frame; 151 EncodedAudioFrame encrypted_frame;
152 if (!EncryptAudioFrame(*audio_frame.get(), &encrypted_frame)) { 152 if (!EncryptAudioFrame(*audio_frame.get(), &encrypted_frame)) {
153 // Logging already done. 153 // Logging already done.
154 return; 154 return;
155 } 155 }
156 rtp_sender_.IncomingEncodedAudioFrame(&encrypted_frame, recorded_time); 156 rtp_sender_.IncomingEncodedAudioFrame(&encrypted_frame, recorded_time);
157 } else { 157 } else {
158 rtp_sender_.IncomingEncodedAudioFrame(audio_frame.get(), recorded_time); 158 rtp_sender_.IncomingEncodedAudioFrame(audio_frame.get(), recorded_time);
159 } 159 }
160 } 160 }
161 161
162 bool AudioSender::EncryptAudioFrame( 162 bool AudioSender::EncryptAudioFrame(const EncodedAudioFrame& audio_frame,
163 const transport::EncodedAudioFrame& audio_frame, 163 EncodedAudioFrame* encrypted_frame) {
164 transport::EncodedAudioFrame* encrypted_frame) {
165 DCHECK(encryptor_) << "Invalid state"; 164 DCHECK(encryptor_) << "Invalid state";
166 165
167 if (!encryptor_->SetCounter(GetAesNonce(audio_frame.frame_id, iv_mask_))) { 166 if (!encryptor_->SetCounter(GetAesNonce(audio_frame.frame_id, iv_mask_))) {
168 NOTREACHED() << "Failed to set counter"; 167 NOTREACHED() << "Failed to set counter";
169 return false; 168 return false;
170 } 169 }
171 if (!encryptor_->Encrypt(audio_frame.data, &encrypted_frame->data)) { 170 if (!encryptor_->Encrypt(audio_frame.data, &encrypted_frame->data)) {
172 NOTREACHED() << "Encrypt error"; 171 NOTREACHED() << "Encrypt error";
173 return false; 172 return false;
174 } 173 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 void AudioSender::SendRtcpReport() { 206 void AudioSender::SendRtcpReport() {
208 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 207 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
209 // We don't send audio logging messages since all captured audio frames will 208 // We don't send audio logging messages since all captured audio frames will
210 // be sent. 209 // be sent.
211 rtcp_.SendRtcpFromRtpSender(NULL); 210 rtcp_.SendRtcpFromRtpSender(NULL);
212 ScheduleNextRtcpReport(); 211 ScheduleNextRtcpReport();
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/audio_sender/audio_sender_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698