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

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

Issue 314593002: [Cast] Cleanup: Remove TransportXXXXXSender, an unnecessary layer of indirection. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Restored/Improved CastSenderImpl VLOGging. Created 6 years, 6 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 #ifndef MEDIA_CAST_AUDIO_SENDER_H_ 5 #ifndef MEDIA_CAST_AUDIO_SENDER_H_
6 #define MEDIA_CAST_AUDIO_SENDER_H_ 6 #define MEDIA_CAST_AUDIO_SENDER_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/threading/non_thread_safe.h" 12 #include "base/threading/non_thread_safe.h"
13 #include "base/time/tick_clock.h" 13 #include "base/time/tick_clock.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "media/base/audio_bus.h" 15 #include "media/base/audio_bus.h"
16 #include "media/cast/cast_config.h" 16 #include "media/cast/cast_config.h"
17 #include "media/cast/rtcp/rtcp.h" 17 #include "media/cast/rtcp/rtcp.h"
18 #include "media/cast/rtp_timestamp_helper.h" 18 #include "media/cast/rtp_timestamp_helper.h"
19 #include "media/cast/transport/rtp_sender/rtp_sender.h" 19 #include "media/cast/transport/utility/transport_encryption_handler.h"
20 20
21 namespace media { 21 namespace media {
22 namespace cast { 22 namespace cast {
23 23
24 class AudioEncoder; 24 class AudioEncoder;
25 25
26 // This class is not thread safe. 26 // This class is not thread safe.
27 // It's only called from the main cast thread. 27 // It's only called from the main cast thread.
28 class AudioSender : public RtcpSenderFeedback, 28 class AudioSender : public RtcpSenderFeedback,
29 public base::NonThreadSafe, 29 public base::NonThreadSafe,
30 public base::SupportsWeakPtr<AudioSender> { 30 public base::SupportsWeakPtr<AudioSender> {
31 public: 31 public:
32 AudioSender(scoped_refptr<CastEnvironment> cast_environment, 32 AudioSender(scoped_refptr<CastEnvironment> cast_environment,
33 const AudioSenderConfig& audio_config, 33 const AudioSenderConfig& audio_config,
34 transport::CastTransportSender* const transport_sender); 34 transport::CastTransportSender* const transport_sender);
35 35
36 virtual ~AudioSender(); 36 virtual ~AudioSender();
37 37
38 CastInitializationStatus InitializationResult() const { 38 CastInitializationStatus InitializationResult() const {
39 return cast_initialization_cb_; 39 return cast_initialization_status_;
40 } 40 }
41 41
42 // Note: It is invalid to call this method if InitializationResult() returns
43 // anything but STATUS_AUDIO_INITIALIZED.
42 void InsertAudio(scoped_ptr<AudioBus> audio_bus, 44 void InsertAudio(scoped_ptr<AudioBus> audio_bus,
43 const base::TimeTicks& recorded_time); 45 const base::TimeTicks& recorded_time);
44 46
45 // Only called from the main cast thread. 47 // Only called from the main cast thread.
46 void IncomingRtcpPacket(scoped_ptr<Packet> packet); 48 void IncomingRtcpPacket(scoped_ptr<Packet> packet);
47 49
48 protected:
49 void SendEncodedAudioFrame(scoped_ptr<transport::EncodedFrame> audio_frame);
50
51 private: 50 private:
52 void ResendPackets( 51 void ResendPackets(
53 const MissingFramesAndPacketsMap& missing_frames_and_packets); 52 const MissingFramesAndPacketsMap& missing_frames_and_packets);
54 53
55 void ScheduleNextRtcpReport(); 54 void ScheduleNextRtcpReport();
56 void SendRtcpReport(bool schedule_future_reports); 55 void SendRtcpReport(bool schedule_future_reports);
57 56
57 // Called by the |audio_encoder_| with the next EncodedFrame to send. If
58 // encryption is enabled, |encoded_frame->data| is encrypted before sending
59 // using |transport_sender_|.
60 void SendEncodedAudioFrame(scoped_ptr<transport::EncodedFrame> audio_frame);
61
58 virtual void OnReceivedCastFeedback(const RtcpCastMessage& cast_feedback) 62 virtual void OnReceivedCastFeedback(const RtcpCastMessage& cast_feedback)
59 OVERRIDE; 63 OVERRIDE;
60 64
61 scoped_refptr<CastEnvironment> cast_environment_; 65 scoped_refptr<CastEnvironment> cast_environment_;
62 transport::CastTransportSender* const transport_sender_; 66 transport::CastTransportSender* const transport_sender_;
63 scoped_ptr<AudioEncoder> audio_encoder_; 67 scoped_ptr<AudioEncoder> audio_encoder_;
64 RtpTimestampHelper rtp_timestamp_helper_; 68 RtpTimestampHelper rtp_timestamp_helper_;
65 Rtcp rtcp_; 69 Rtcp rtcp_;
66 int num_aggressive_rtcp_reports_sent_; 70 int num_aggressive_rtcp_reports_sent_;
67 CastInitializationStatus cast_initialization_cb_; 71
72 // Encrypts data in EncodedFrames before they are sent.
73 transport::TransportEncryptionHandler encryptor_;
Alpha Left Google 2014/06/03 20:01:52 It is by design to have encryption done in the tra
miu 2014/06/03 21:55:15 Done.
74
75 // If this sender is ready for use, this is STATUS_AUDIO_INITIALIZED.
76 CastInitializationStatus cast_initialization_status_;
68 77
69 // Used to map the lower 8 bits of the frame id to a RTP timestamp. This is 78 // Used to map the lower 8 bits of the frame id to a RTP timestamp. This is
70 // good enough as we only use it for logging. 79 // good enough as we only use it for logging.
71 RtpTimestamp frame_id_to_rtp_timestamp_[256]; 80 RtpTimestamp frame_id_to_rtp_timestamp_[256];
72 81
73 // NOTE: Weak pointers must be invalidated before all other member variables. 82 // NOTE: Weak pointers must be invalidated before all other member variables.
74 base::WeakPtrFactory<AudioSender> weak_factory_; 83 base::WeakPtrFactory<AudioSender> weak_factory_;
75 84
76 DISALLOW_COPY_AND_ASSIGN(AudioSender); 85 DISALLOW_COPY_AND_ASSIGN(AudioSender);
77 }; 86 };
78 87
79 } // namespace cast 88 } // namespace cast
80 } // namespace media 89 } // namespace media
81 90
82 #endif // MEDIA_CAST_AUDIO_SENDER_H_ 91 #endif // MEDIA_CAST_AUDIO_SENDER_H_
OLDNEW
« no previous file with comments | « no previous file | media/cast/audio_sender/audio_sender.cc » ('j') | media/cast/video_sender/video_sender.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698