Report errors from ChromiumEnv::GetChildren in Posix.
[chromium-blink-merge.git] / media / cast / cast_config.h
blob7a123ce06fa6b0f0c26773db3f3bb3bf61def9d7
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 <list>
9 #include <string>
10 #include <vector>
12 #include "base/basictypes.h"
13 #include "base/callback.h"
14 #include "base/memory/ref_counted.h"
15 #include "media/cast/cast_defines.h"
17 namespace media {
18 namespace cast {
20 enum RtcpMode {
21 kRtcpCompound, // Compound RTCP mode is described by RFC 4585.
22 kRtcpReducedSize, // Reduced-size RTCP mode is described by RFC 5506.
25 enum VideoCodec {
26 kVp8,
27 kH264,
28 kExternalVideo,
31 enum AudioCodec {
32 kOpus,
33 kPcm16,
34 kExternalAudio,
37 struct AudioSenderConfig {
38 AudioSenderConfig();
40 uint32 sender_ssrc;
41 uint32 incoming_feedback_ssrc;
43 int rtcp_interval;
44 std::string rtcp_c_name;
45 RtcpMode rtcp_mode;
47 int rtp_history_ms; // The time RTP packets are stored for retransmissions.
48 int rtp_max_delay_ms;
49 int rtp_payload_type;
51 bool use_external_encoder;
52 int frequency;
53 int channels;
54 int bitrate;
55 AudioCodec codec;
58 struct VideoSenderConfig {
59 VideoSenderConfig();
61 uint32 sender_ssrc;
62 uint32 incoming_feedback_ssrc;
64 int rtcp_interval;
65 std::string rtcp_c_name;
66 RtcpMode rtcp_mode;
68 int rtp_history_ms; // The time RTP packets are stored for retransmissions.
69 int rtp_max_delay_ms;
70 int rtp_payload_type;
72 bool use_external_encoder;
73 int width; // Incoming frames will be scaled to this size.
74 int height;
76 float congestion_control_back_off;
77 int max_bitrate;
78 int min_bitrate;
79 int start_bitrate;
80 int max_qp;
81 int min_qp;
82 int max_frame_rate;
83 int max_number_of_video_buffers_used; // Max value depend on codec.
84 VideoCodec codec;
85 int number_of_cores;
88 struct AudioReceiverConfig {
89 AudioReceiverConfig();
91 uint32 feedback_ssrc;
92 uint32 incoming_ssrc;
94 int rtcp_interval;
95 std::string rtcp_c_name;
96 RtcpMode rtcp_mode;
98 // The time the receiver is prepared to wait for retransmissions.
99 int rtp_max_delay_ms;
100 int rtp_payload_type;
102 bool use_external_decoder;
103 int frequency;
104 int channels;
105 AudioCodec codec;
108 struct VideoReceiverConfig {
109 VideoReceiverConfig();
111 uint32 feedback_ssrc;
112 uint32 incoming_ssrc;
114 int rtcp_interval;
115 std::string rtcp_c_name;
116 RtcpMode rtcp_mode;
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;
123 int max_frame_rate;
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;
128 VideoCodec codec;
131 struct I420VideoPlane {
132 int stride;
133 int length;
134 uint8* data;
137 struct I420VideoFrame {
138 int width;
139 int height;
140 I420VideoPlane y_plane;
141 I420VideoPlane u_plane;
142 I420VideoPlane v_plane;
145 struct EncodedVideoFrame {
146 EncodedVideoFrame();
147 ~EncodedVideoFrame();
149 VideoCodec codec;
150 bool key_frame;
151 uint8 frame_id;
152 uint8 last_referenced_frame_id;
153 std::vector<uint8> data;
156 struct PcmAudioFrame {
157 PcmAudioFrame();
158 ~PcmAudioFrame();
160 int channels; // Samples in interleaved stereo format. L0, R0, L1 ,R1 ,...
161 int frequency;
162 std::vector<int16> samples;
165 struct EncodedAudioFrame {
166 EncodedAudioFrame();
167 ~EncodedAudioFrame();
169 AudioCodec codec;
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;
179 class PacketSender {
180 public:
181 // All packets to be sent to the network will be delivered via these
182 // functions.
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> {
191 public:
192 // All packets received from the network should be delivered via this
193 // function.
194 virtual void ReceivedPacket(const uint8* packet, int length,
195 const base::Closure callback) = 0;
197 static void DeletePacket(const uint8* packet);
199 protected:
200 virtual ~PacketReceiver() {}
202 private:
203 friend class base::RefCountedThreadSafe<PacketReceiver>;
206 class VideoEncoderController {
207 public:
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;
224 protected:
225 virtual ~VideoEncoderController() {}
228 } // namespace cast
229 } // namespace media
231 #endif // MEDIA_CAST_CAST_CONFIG_H_