Allow overlapping sync and async startup requests
[chromium-blink-merge.git] / media / cast / cast_config.h
blobe1280cd03bed6355ca2af2ad1ec5c9aae4b11435
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_
8 #include <string>
9 #include <vector>
11 #include "base/basictypes.h"
12 #include "media/cast/cast_defines.h"
14 namespace media {
15 namespace cast {
17 enum RtcpMode {
18 kRtcpCompound, // Compound RTCP mode is described by RFC 4585.
19 kRtcpReducedSize, // Reduced-size RTCP mode is described by RFC 5506.
22 enum VideoCodec {
23 kVp8,
24 kH264,
25 kExternalVideo,
28 enum AudioCodec {
29 kOpus,
30 kPcm16,
31 kExternalAudio,
34 struct AudioSenderConfig {
35 AudioSenderConfig();
37 uint32 sender_ssrc;
38 uint32 incoming_feedback_ssrc;
40 int rtcp_interval;
41 std::string rtcp_c_name;
42 RtcpMode rtcp_mode;
44 int rtp_history_ms; // The time RTP packets are stored for retransmissions.
45 int rtp_max_delay_ms;
46 int rtp_payload_type;
48 bool use_external_encoder;
49 int frequency;
50 int channels;
51 int bitrate;
52 AudioCodec codec;
55 struct VideoSenderConfig {
56 VideoSenderConfig();
58 uint32 sender_ssrc;
59 uint32 incoming_feedback_ssrc;
61 int rtcp_interval;
62 std::string rtcp_c_name;
63 RtcpMode rtcp_mode;
65 int rtp_history_ms; // The time RTP packets are stored for retransmissions.
66 int rtp_max_delay_ms;
67 int rtp_payload_type;
69 bool use_external_encoder;
70 int width; // Incoming frames will be scaled to this size.
71 int height;
73 float congestion_control_back_off;
74 int max_bitrate;
75 int min_bitrate;
76 int start_bitrate;
77 int max_qp;
78 int min_qp;
79 int max_frame_rate;
80 int max_number_of_video_buffers_used; // Max value depend on codec.
81 VideoCodec codec;
82 int number_of_cores;
85 struct AudioReceiverConfig {
86 AudioReceiverConfig();
88 uint32 feedback_ssrc;
89 uint32 incoming_ssrc;
91 int rtcp_interval;
92 std::string rtcp_c_name;
93 RtcpMode rtcp_mode;
95 // The time the receiver is prepared to wait for retransmissions.
96 int rtp_max_delay_ms;
97 int rtp_payload_type;
99 bool use_external_decoder;
100 int frequency;
101 int channels;
102 AudioCodec codec;
105 struct VideoReceiverConfig {
106 VideoReceiverConfig();
108 uint32 feedback_ssrc;
109 uint32 incoming_ssrc;
111 int rtcp_interval;
112 std::string rtcp_c_name;
113 RtcpMode rtcp_mode;
115 // The time the receiver is prepared to wait for retransmissions.
116 int rtp_max_delay_ms;
117 int rtp_payload_type;
119 bool use_external_decoder;
120 int max_frame_rate;
122 // Some HW decoders can not run faster than the frame rate, preventing it
123 // from catching up after a glitch.
124 bool decoder_faster_than_max_frame_rate;
125 VideoCodec codec;
128 struct I420VideoPlane {
129 int stride;
130 int length;
131 uint8* data;
134 struct I420VideoFrame {
135 int width;
136 int height;
137 I420VideoPlane y_plane;
138 I420VideoPlane u_plane;
139 I420VideoPlane v_plane;
142 struct EncodedVideoFrame {
143 EncodedVideoFrame();
144 ~EncodedVideoFrame();
146 VideoCodec codec;
147 bool key_frame;
148 uint8 frame_id;
149 uint8 last_referenced_frame_id;
150 std::vector<uint8> data;
153 struct PcmAudioFrame {
154 PcmAudioFrame();
155 ~PcmAudioFrame();
157 int channels; // Samples in interleaved stereo format. L0, R0, L1 ,R1 ,...
158 int frequency;
159 std::vector<int16> samples;
162 struct EncodedAudioFrame {
163 EncodedAudioFrame();
164 ~EncodedAudioFrame();
166 AudioCodec codec;
167 uint8 frame_id; // Needed to release the frame. Not used send side.
168 int samples; // Needed send side to advance the RTP timestamp.
169 // Not used receive side.
170 std::vector<uint8> data;
173 class PacketSender {
174 public:
175 // All packets to be sent to the network will be delivered via this function.
176 virtual bool SendPacket(const uint8* packet, int length) = 0;
178 protected:
179 virtual ~PacketSender() {}
182 class PacketReceiver {
183 public:
184 // All packets received from the network should be delivered via this
185 // function.
186 virtual void ReceivedPacket(const uint8* packet, int length) = 0;
188 protected:
189 virtual ~PacketReceiver() {}
192 class VideoEncoderController {
193 public:
194 // Inform the encoder about the new target bit rate.
195 virtual void SetBitRate(int new_bit_rate) = 0;
197 // Inform the encoder to not encode the next frame.
198 // Note: this setting is sticky and should last until called with false.
199 virtual void SkipNextFrame(bool skip_next_frame) = 0;
201 // Inform the encoder to encode the next frame as a key frame.
202 virtual void GenerateKeyFrame() = 0;
204 // Inform the encoder to only reference frames older or equal to frame_id;
205 virtual void LatestFrameIdToReference(uint8 frame_id) = 0;
207 // Query the codec about how many frames it has skipped due to slow ACK.
208 virtual int NumberOfSkippedFrames() const = 0;
210 protected:
211 virtual ~VideoEncoderController() {}
214 } // namespace cast
215 } // namespace media
217 #endif // MEDIA_CAST_CAST_CONFIG_H_