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
3 // found in the LICENSE file.
5 #ifndef MEDIA_CAST_CAST_CONFIG_H_
6 #define MEDIA_CAST_CAST_CONFIG_H_
12 #include "base/basictypes.h"
13 #include "base/callback.h"
14 #include "base/memory/ref_counted.h"
15 #include "media/cast/cast_defines.h"
21 kRtcpCompound
, // Compound RTCP mode is described by RFC 4585.
22 kRtcpReducedSize
, // Reduced-size RTCP mode is described by RFC 5506.
37 struct AudioSenderConfig
{
41 uint32 incoming_feedback_ssrc
;
44 std::string rtcp_c_name
;
47 int rtp_history_ms
; // The time RTP packets are stored for retransmissions.
51 bool use_external_encoder
;
58 struct VideoSenderConfig
{
62 uint32 incoming_feedback_ssrc
;
65 std::string rtcp_c_name
;
68 int rtp_history_ms
; // The time RTP packets are stored for retransmissions.
72 bool use_external_encoder
;
73 int width
; // Incoming frames will be scaled to this size.
76 float congestion_control_back_off
;
83 int max_number_of_video_buffers_used
; // Max value depend on codec.
88 struct AudioReceiverConfig
{
89 AudioReceiverConfig();
95 std::string rtcp_c_name
;
98 // The time the receiver is prepared to wait for retransmissions.
100 int rtp_payload_type
;
102 bool use_external_decoder
;
108 struct VideoReceiverConfig
{
109 VideoReceiverConfig();
111 uint32 feedback_ssrc
;
112 uint32 incoming_ssrc
;
115 std::string rtcp_c_name
;
118 // The time the receiver is prepared to wait for retransmissions.
119 int rtp_max_delay_ms
;
120 int rtp_payload_type
;
122 bool use_external_decoder
;
125 // Some HW decoders can not run faster than the frame rate, preventing it
126 // from catching up after a glitch.
127 bool decoder_faster_than_max_frame_rate
;
131 struct I420VideoPlane
{
137 struct I420VideoFrame
{
140 I420VideoPlane y_plane
;
141 I420VideoPlane u_plane
;
142 I420VideoPlane v_plane
;
145 struct EncodedVideoFrame
{
147 ~EncodedVideoFrame();
152 uint8 last_referenced_frame_id
;
153 std::vector
<uint8
> data
;
156 struct PcmAudioFrame
{
160 int channels
; // Samples in interleaved stereo format. L0, R0, L1 ,R1 ,...
162 std::vector
<int16
> samples
;
165 struct EncodedAudioFrame
{
167 ~EncodedAudioFrame();
170 uint8 frame_id
; // Needed to release the frame. Not used send side.
171 int samples
; // Needed send side to advance the RTP timestamp.
172 // Not used receive side.
173 std::vector
<uint8
> data
;
176 typedef std::vector
<uint8
> Packet
;
177 typedef std::vector
<Packet
> PacketList
;
181 // All packets to be sent to the network will be delivered via these
183 virtual bool SendPackets(const PacketList
& packets
) = 0;
185 virtual bool SendPacket(const Packet
& packet
) = 0;
187 virtual ~PacketSender() {}
190 class PacketReceiver
: public base::RefCountedThreadSafe
<PacketReceiver
> {
192 // All packets received from the network should be delivered via this
194 virtual void ReceivedPacket(const uint8
* packet
, int length
,
195 const base::Closure callback
) = 0;
197 static void DeletePacket(const uint8
* packet
);
200 virtual ~PacketReceiver() {}
203 friend class base::RefCountedThreadSafe
<PacketReceiver
>;
206 class VideoEncoderController
{
208 // Inform the encoder about the new target bit rate.
209 virtual void SetBitRate(int new_bit_rate
) = 0;
211 // Inform the encoder to not encode the next frame.
212 // Note: this setting is sticky and should last until called with false.
213 virtual void SkipNextFrame(bool skip_next_frame
) = 0;
215 // Inform the encoder to encode the next frame as a key frame.
216 virtual void GenerateKeyFrame() = 0;
218 // Inform the encoder to only reference frames older or equal to frame_id;
219 virtual void LatestFrameIdToReference(uint8 frame_id
) = 0;
221 // Query the codec about how many frames it has skipped due to slow ACK.
222 virtual int NumberOfSkippedFrames() const = 0;
225 virtual ~VideoEncoderController() {}
231 #endif // MEDIA_CAST_CAST_CONFIG_H_