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

Side by Side Diff: media/cast/receiver/cast_receiver_impl.h

Issue 308043006: [Cast] Clean-up: Merge RtpReceiver+AudioReceiver+VideoReceiver-->FrameReceiver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed hclam's comments. 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_CAST_RECEIVER_IMPL_H_ 5 #ifndef MEDIA_CAST_RECEIVER_CAST_RECEIVER_IMPL_H_
6 #define MEDIA_CAST_CAST_RECEIVER_IMPL_H_ 6 #define MEDIA_CAST_RECEIVER_CAST_RECEIVER_IMPL_H_
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "media/cast/audio_receiver/audio_receiver.h"
11 #include "media/cast/cast_config.h" 10 #include "media/cast/cast_config.h"
12 #include "media/cast/cast_environment.h" 11 #include "media/cast/cast_environment.h"
13 #include "media/cast/cast_receiver.h" 12 #include "media/cast/cast_receiver.h"
13 #include "media/cast/receiver/frame_receiver.h"
14 #include "media/cast/transport/pacing/paced_sender.h" 14 #include "media/cast/transport/pacing/paced_sender.h"
15 #include "media/cast/video_receiver/video_receiver.h"
16 15
17 namespace media { 16 namespace media {
18 namespace cast { 17 namespace cast {
19 // This calls is a pure owner class that group all required receive objects 18
20 // together such as pacer, packet receiver, frame receiver, audio and video 19 class AudioDecoder;
21 // receivers. 20 class VideoDecoder;
21
22 // This is a pure owner class that groups all required receiver-related objects
23 // together, such as the paced packet sender, audio/video RTP frame receivers,
24 // and software decoders (created on-demand).
22 class CastReceiverImpl : public CastReceiver { 25 class CastReceiverImpl : public CastReceiver {
23 public: 26 public:
24 CastReceiverImpl(scoped_refptr<CastEnvironment> cast_environment, 27 CastReceiverImpl(scoped_refptr<CastEnvironment> cast_environment,
25 const FrameReceiverConfig& audio_config, 28 const FrameReceiverConfig& audio_config,
26 const FrameReceiverConfig& video_config, 29 const FrameReceiverConfig& video_config,
27 transport::PacketSender* const packet_sender); 30 transport::PacketSender* const packet_sender);
28 31
29 virtual ~CastReceiverImpl(); 32 virtual ~CastReceiverImpl();
30 33
31 // All received RTP and RTCP packets for the call should be sent to this 34 // CastReceiver implementation.
32 // PacketReceiver;
33 virtual transport::PacketReceiverCallback packet_receiver() OVERRIDE; 35 virtual transport::PacketReceiverCallback packet_receiver() OVERRIDE;
34 36 virtual void RequestDecodedAudioFrame(
35 // Interface to get audio and video frames from the CastReceiver. 37 const AudioFrameDecodedCallback& callback) OVERRIDE;
36 virtual scoped_refptr<FrameReceiver> frame_receiver() OVERRIDE; 38 virtual void RequestEncodedAudioFrame(
39 const ReceiveEncodedFrameCallback& callback) OVERRIDE;
40 virtual void RequestDecodedVideoFrame(
41 const VideoFrameDecodedCallback& callback) OVERRIDE;
42 virtual void RequestEncodedVideoFrame(
43 const ReceiveEncodedFrameCallback& callback) OVERRIDE;
37 44
38 private: 45 private:
39 void ReceivedPacket(scoped_ptr<Packet> packet); 46 // Forwards |packet| to a specific RTP frame receiver, or drops it if SSRC
47 // does not map to one of the receivers.
48 void DispatchReceivedPacket(scoped_ptr<Packet> packet);
40 49
50 // Feeds an EncodedFrame into |audio_decoder_|. RequestDecodedAudioFrame()
51 // uses this as a callback for RequestEncodedAudioFrame().
52 void DecodeEncodedAudioFrame(
53 const AudioFrameDecodedCallback& callback,
54 scoped_ptr<transport::EncodedFrame> encoded_frame);
55
56 // Feeds an EncodedFrame into |video_decoder_|. RequestDecodedVideoFrame()
57 // uses this as a callback for RequestEncodedVideoFrame().
58 void DecodeEncodedVideoFrame(
59 const VideoFrameDecodedCallback& callback,
60 scoped_ptr<transport::EncodedFrame> encoded_frame);
61
62 // Receives an AudioBus from |audio_decoder_|, logs the event, and passes the
63 // data on by running the given |callback|. This method is static to ensure
64 // it can be called after a CastReceiverImpl instance is destroyed.
65 // DecodeEncodedAudioFrame() uses this as a callback for
66 // AudioDecoder::DecodeFrame().
67 static void EmitDecodedAudioFrame(
68 const scoped_refptr<CastEnvironment>& cast_environment,
69 const AudioFrameDecodedCallback& callback,
70 uint32 frame_id,
71 uint32 rtp_timestamp,
72 const base::TimeTicks& playout_time,
73 scoped_ptr<AudioBus> audio_bus,
74 bool is_continuous);
75
76 // Receives a VideoFrame from |video_decoder_|, logs the event, and passes the
77 // data on by running the given |callback|. This method is static to ensure
78 // it can be called after a CastReceiverImpl instance is destroyed.
79 // DecodeEncodedVideoFrame() uses this as a callback for
80 // VideoDecoder::DecodeFrame().
81 static void EmitDecodedVideoFrame(
82 const scoped_refptr<CastEnvironment>& cast_environment,
83 const VideoFrameDecodedCallback& callback,
84 uint32 frame_id,
85 uint32 rtp_timestamp,
86 const base::TimeTicks& playout_time,
87 const scoped_refptr<VideoFrame>& video_frame,
88 bool is_continuous);
89
90 const scoped_refptr<CastEnvironment> cast_environment_;
41 transport::PacedSender pacer_; 91 transport::PacedSender pacer_;
42 AudioReceiver audio_receiver_; 92 FrameReceiver audio_receiver_;
43 VideoReceiver video_receiver_; 93 FrameReceiver video_receiver_;
44 scoped_refptr<FrameReceiver> frame_receiver_; 94
45 scoped_refptr<CastEnvironment> cast_environment_; 95 // Used by DispatchReceivedPacket() to direct packets to the appropriate frame
96 // receiver.
46 const uint32 ssrc_of_audio_sender_; 97 const uint32 ssrc_of_audio_sender_;
47 const uint32 ssrc_of_video_sender_; 98 const uint32 ssrc_of_video_sender_;
48 99
100 // Parameters for the decoders that are created on-demand. The values here
101 // might be nonsense if the client of CastReceiverImpl never intends to use
102 // the internal software-based decoders.
103 const int num_audio_channels_;
104 const int audio_sampling_rate_;
105 const transport::AudioCodec audio_codec_;
106 const transport::VideoCodec video_codec_;
107
108 // Created on-demand to decode frames from |audio_receiver_| into AudioBuses
109 // for playback.
110 scoped_ptr<AudioDecoder> audio_decoder_;
111
112 // Created on-demand to decode frames from |video_receiver_| into VideoFrame
113 // images for playback.
114 scoped_ptr<VideoDecoder> video_decoder_;
115
49 DISALLOW_COPY_AND_ASSIGN(CastReceiverImpl); 116 DISALLOW_COPY_AND_ASSIGN(CastReceiverImpl);
50 }; 117 };
51 118
52 } // namespace cast 119 } // namespace cast
53 } // namespace media 120 } // namespace media
54 121
55 #endif // MEDIA_CAST_CAST_RECEIVER_IMPL_ 122 #endif // MEDIA_CAST_RECEIVER_CAST_RECEIVER_IMPL_
OLDNEW
« no previous file with comments | « media/cast/receiver/audio_decoder_unittest.cc ('k') | media/cast/receiver/cast_receiver_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698