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_
11 #include "base/basictypes.h"
12 #include "base/callback.h"
13 #include "base/memory/ref_counted.h"
14 #include "media/cast/cast_defines.h"
20 kRtcpCompound
, // Compound RTCP mode is described by RFC 4585.
21 kRtcpReducedSize
, // Reduced-size RTCP mode is described by RFC 5506.
36 struct AudioSenderConfig
{
40 uint32 incoming_feedback_ssrc
;
43 std::string rtcp_c_name
;
46 int rtp_history_ms
; // The time RTP packets are stored for retransmissions.
50 bool use_external_encoder
;
57 struct VideoSenderConfig
{
61 uint32 incoming_feedback_ssrc
;
64 std::string rtcp_c_name
;
67 int rtp_history_ms
; // The time RTP packets are stored for retransmissions.
71 bool use_external_encoder
;
72 int width
; // Incoming frames will be scaled to this size.
75 float congestion_control_back_off
;
82 int max_number_of_video_buffers_used
; // Max value depend on codec.
87 struct AudioReceiverConfig
{
88 AudioReceiverConfig();
94 std::string rtcp_c_name
;
97 // The time the receiver is prepared to wait for retransmissions.
101 bool use_external_decoder
;
107 struct VideoReceiverConfig
{
108 VideoReceiverConfig();
110 uint32 feedback_ssrc
;
111 uint32 incoming_ssrc
;
114 std::string rtcp_c_name
;
117 // The time the receiver is prepared to wait for retransmissions.
118 int rtp_max_delay_ms
;
119 int rtp_payload_type
;
121 bool use_external_decoder
;
124 // Some HW decoders can not run faster than the frame rate, preventing it
125 // from catching up after a glitch.
126 bool decoder_faster_than_max_frame_rate
;
130 struct I420VideoPlane
{
136 struct I420VideoFrame
{
139 I420VideoPlane y_plane
;
140 I420VideoPlane u_plane
;
141 I420VideoPlane v_plane
;
144 struct EncodedVideoFrame
{
146 ~EncodedVideoFrame();
151 uint8 last_referenced_frame_id
;
152 std::vector
<uint8
> data
;
155 struct PcmAudioFrame
{
159 int channels
; // Samples in interleaved stereo format. L0, R0, L1 ,R1 ,...
161 std::vector
<int16
> samples
;
164 struct EncodedAudioFrame
{
166 ~EncodedAudioFrame();
169 uint8 frame_id
; // Needed to release the frame. Not used send side.
170 int samples
; // Needed send side to advance the RTP timestamp.
171 // Not used receive side.
172 std::vector
<uint8
> data
;
177 // All packets to be sent to the network will be delivered via this function.
178 virtual bool SendPacket(const uint8
* packet
, int length
) = 0;
180 virtual ~PacketSender() {}
183 class PacketReceiver
: public base::RefCountedThreadSafe
<PacketReceiver
> {
185 // All packets received from the network should be delivered via this
187 virtual void ReceivedPacket(const uint8
* packet
, int length
,
188 const base::Closure callback
) = 0;
190 virtual ~PacketReceiver() {}
193 class VideoEncoderController
{
195 // Inform the encoder about the new target bit rate.
196 virtual void SetBitRate(int new_bit_rate
) = 0;
198 // Inform the encoder to not encode the next frame.
199 // Note: this setting is sticky and should last until called with false.
200 virtual void SkipNextFrame(bool skip_next_frame
) = 0;
202 // Inform the encoder to encode the next frame as a key frame.
203 virtual void GenerateKeyFrame() = 0;
205 // Inform the encoder to only reference frames older or equal to frame_id;
206 virtual void LatestFrameIdToReference(uint8 frame_id
) = 0;
208 // Query the codec about how many frames it has skipped due to slow ACK.
209 virtual int NumberOfSkippedFrames() const = 0;
212 virtual ~VideoEncoderController() {}
218 #endif // MEDIA_CAST_CAST_CONFIG_H_