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

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

Issue 2133223003: Revert of Refactoring: Merge VideoSenderConfig and AudioSenderConfig. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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/cast/sender/audio_sender.h ('k') | media/cast/sender/audio_sender_unittest.cc » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/sender/audio_sender.h" 5 #include "media/cast/sender/audio_sender.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "media/cast/common/rtp_time.h" 13 #include "media/cast/common/rtp_time.h"
14 #include "media/cast/net/cast_transport_config.h" 14 #include "media/cast/net/cast_transport_config.h"
15 #include "media/cast/sender/audio_encoder.h" 15 #include "media/cast/sender/audio_encoder.h"
16 16
17 namespace media { 17 namespace media {
18 namespace cast { 18 namespace cast {
19 19
20 AudioSender::AudioSender(scoped_refptr<CastEnvironment> cast_environment, 20 AudioSender::AudioSender(scoped_refptr<CastEnvironment> cast_environment,
21 const FrameSenderConfig& audio_config, 21 const AudioSenderConfig& audio_config,
22 const StatusChangeCallback& status_change_cb, 22 const StatusChangeCallback& status_change_cb,
23 CastTransport* const transport_sender) 23 CastTransport* const transport_sender)
24 : FrameSender(cast_environment, 24 : FrameSender(cast_environment,
25 true, 25 true,
26 transport_sender, 26 transport_sender,
27 audio_config.rtp_timebase, 27 audio_config.frequency,
28 audio_config.sender_ssrc, 28 audio_config.ssrc,
29 0, // |max_frame_rate_| is set after encoder initialization. 29 0, // |max_frame_rate_| is set after encoder initialization.
30 audio_config.min_playout_delay, 30 audio_config.min_playout_delay,
31 audio_config.max_playout_delay, 31 audio_config.max_playout_delay,
32 audio_config.animated_playout_delay, 32 audio_config.animated_playout_delay,
33 NewFixedCongestionControl(audio_config.max_bitrate)), 33 NewFixedCongestionControl(audio_config.bitrate)),
34 samples_in_encoder_(0), 34 samples_in_encoder_(0),
35 weak_factory_(this) { 35 weak_factory_(this) {
36 if (!audio_config.use_external_encoder) { 36 if (!audio_config.use_external_encoder) {
37 audio_encoder_.reset(new AudioEncoder( 37 audio_encoder_.reset(
38 cast_environment, audio_config.channels, audio_config.rtp_timebase, 38 new AudioEncoder(cast_environment,
39 audio_config.max_bitrate, audio_config.codec, 39 audio_config.channels,
40 base::Bind(&AudioSender::OnEncodedAudioFrame, 40 audio_config.frequency,
41 weak_factory_.GetWeakPtr(), audio_config.max_bitrate))); 41 audio_config.bitrate,
42 audio_config.codec,
43 base::Bind(&AudioSender::OnEncodedAudioFrame,
44 weak_factory_.GetWeakPtr(),
45 audio_config.bitrate)));
42 } 46 }
43 47
44 // AudioEncoder provides no operational status changes during normal use. 48 // AudioEncoder provides no operational status changes during normal use.
45 // Post a task now with its initialization result status to allow the client 49 // Post a task now with its initialization result status to allow the client
46 // to start sending frames. 50 // to start sending frames.
47 cast_environment_->PostTask( 51 cast_environment_->PostTask(
48 CastEnvironment::MAIN, 52 CastEnvironment::MAIN,
49 FROM_HERE, 53 FROM_HERE,
50 base::Bind(status_change_cb, 54 base::Bind(status_change_cb,
51 audio_encoder_ ? audio_encoder_->InitializationResult() : 55 audio_encoder_ ? audio_encoder_->InitializationResult() :
52 STATUS_INVALID_CONFIGURATION)); 56 STATUS_INVALID_CONFIGURATION));
53 57
54 // The number of samples per encoded audio frame depends on the codec and its 58 // The number of samples per encoded audio frame depends on the codec and its
55 // initialization parameters. Now that we have an encoder, we can calculate 59 // initialization parameters. Now that we have an encoder, we can calculate
56 // the maximum frame rate. 60 // the maximum frame rate.
57 max_frame_rate_ = 61 max_frame_rate_ =
58 audio_config.rtp_timebase / audio_encoder_->GetSamplesPerFrame(); 62 audio_config.frequency / audio_encoder_->GetSamplesPerFrame();
59 63
60 media::cast::CastTransportRtpConfig transport_config; 64 media::cast::CastTransportRtpConfig transport_config;
61 transport_config.ssrc = audio_config.sender_ssrc; 65 transport_config.ssrc = audio_config.ssrc;
62 transport_config.feedback_ssrc = audio_config.receiver_ssrc; 66 transport_config.feedback_ssrc = audio_config.receiver_ssrc;
63 transport_config.rtp_payload_type = audio_config.rtp_payload_type; 67 transport_config.rtp_payload_type = audio_config.rtp_payload_type;
64 transport_config.aes_key = audio_config.aes_key; 68 transport_config.aes_key = audio_config.aes_key;
65 transport_config.aes_iv_mask = audio_config.aes_iv_mask; 69 transport_config.aes_iv_mask = audio_config.aes_iv_mask;
66 70
67 transport_sender->InitializeAudio( 71 transport_sender->InitializeAudio(
68 transport_config, base::WrapUnique(new FrameSender::RtcpClient( 72 transport_config, base::WrapUnique(new FrameSender::RtcpClient(
69 weak_factory_.GetWeakPtr()))); 73 weak_factory_.GetWeakPtr())));
70 } 74 }
71 75
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 113 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
110 114
111 samples_in_encoder_ -= audio_encoder_->GetSamplesPerFrame() + samples_skipped; 115 samples_in_encoder_ -= audio_encoder_->GetSamplesPerFrame() + samples_skipped;
112 DCHECK_GE(samples_in_encoder_, 0); 116 DCHECK_GE(samples_in_encoder_, 0);
113 117
114 SendEncodedFrame(encoder_bitrate, std::move(encoded_frame)); 118 SendEncodedFrame(encoder_bitrate, std::move(encoded_frame));
115 } 119 }
116 120
117 } // namespace cast 121 } // namespace cast
118 } // namespace media 122 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/sender/audio_sender.h ('k') | media/cast/sender/audio_sender_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698