Revert 224458 "Enabling MediaStreamInfoBarTest.DenyingCameraDoes..."
[chromium-blink-merge.git] / media / cast / cast_config.h
blob988924aab45f76d3d2175a19c822674f8634300a
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 "base/callback.h"
13 #include "base/memory/ref_counted.h"
14 #include "media/cast/cast_defines.h"
16 namespace media {
17 namespace cast {
19 enum RtcpMode {
20 kRtcpCompound, // Compound RTCP mode is described by RFC 4585.
21 kRtcpReducedSize, // Reduced-size RTCP mode is described by RFC 5506.
24 enum VideoCodec {
25 kVp8,
26 kH264,
27 kExternalVideo,
30 enum AudioCodec {
31 kOpus,
32 kPcm16,
33 kExternalAudio,
36 struct AudioSenderConfig {
37 AudioSenderConfig();
39 uint32 sender_ssrc;
40 uint32 incoming_feedback_ssrc;
42 int rtcp_interval;
43 std::string rtcp_c_name;
44 RtcpMode rtcp_mode;
46 int rtp_history_ms; // The time RTP packets are stored for retransmissions.
47 int rtp_max_delay_ms;
48 int rtp_payload_type;
50 bool use_external_encoder;
51 int frequency;
52 int channels;
53 int bitrate;
54 AudioCodec codec;
57 struct VideoSenderConfig {
58 VideoSenderConfig();
60 uint32 sender_ssrc;
61 uint32 incoming_feedback_ssrc;
63 int rtcp_interval;
64 std::string rtcp_c_name;
65 RtcpMode rtcp_mode;
67 int rtp_history_ms; // The time RTP packets are stored for retransmissions.
68 int rtp_max_delay_ms;
69 int rtp_payload_type;
71 bool use_external_encoder;
72 int width; // Incoming frames will be scaled to this size.
73 int height;
75 float congestion_control_back_off;
76 int max_bitrate;
77 int min_bitrate;
78 int start_bitrate;
79 int max_qp;
80 int min_qp;
81 int max_frame_rate;
82 int max_number_of_video_buffers_used; // Max value depend on codec.
83 VideoCodec codec;
84 int number_of_cores;
87 struct AudioReceiverConfig {
88 AudioReceiverConfig();
90 uint32 feedback_ssrc;
91 uint32 incoming_ssrc;
93 int rtcp_interval;
94 std::string rtcp_c_name;
95 RtcpMode rtcp_mode;
97 // The time the receiver is prepared to wait for retransmissions.
98 int rtp_max_delay_ms;
99 int rtp_payload_type;
101 bool use_external_decoder;
102 int frequency;
103 int channels;
104 AudioCodec codec;
107 struct VideoReceiverConfig {
108 VideoReceiverConfig();
110 uint32 feedback_ssrc;
111 uint32 incoming_ssrc;
113 int rtcp_interval;
114 std::string rtcp_c_name;
115 RtcpMode rtcp_mode;
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;
122 int max_frame_rate;
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;
127 VideoCodec codec;
130 struct I420VideoPlane {
131 int stride;
132 int length;
133 uint8* data;
136 struct I420VideoFrame {
137 int width;
138 int height;
139 I420VideoPlane y_plane;
140 I420VideoPlane u_plane;
141 I420VideoPlane v_plane;
144 struct EncodedVideoFrame {
145 EncodedVideoFrame();
146 ~EncodedVideoFrame();
148 VideoCodec codec;
149 bool key_frame;
150 uint8 frame_id;
151 uint8 last_referenced_frame_id;
152 std::vector<uint8> data;
155 struct PcmAudioFrame {
156 PcmAudioFrame();
157 ~PcmAudioFrame();
159 int channels; // Samples in interleaved stereo format. L0, R0, L1 ,R1 ,...
160 int frequency;
161 std::vector<int16> samples;
164 struct EncodedAudioFrame {
165 EncodedAudioFrame();
166 ~EncodedAudioFrame();
168 AudioCodec codec;
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;
175 class PacketSender {
176 public:
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> {
184 public:
185 // All packets received from the network should be delivered via this
186 // function.
187 virtual void ReceivedPacket(const uint8* packet, int length,
188 const base::Closure callback) = 0;
190 virtual ~PacketReceiver() {}
193 class VideoEncoderController {
194 public:
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;
211 protected:
212 virtual ~VideoEncoderController() {}
215 } // namespace cast
216 } // namespace media
218 #endif // MEDIA_CAST_CAST_CONFIG_H_