chrome: Fix dependencies of common_net target.
[chromium-blink-merge.git] / media / cast / cast_config.h
blob36ed104f93b1b2f734c68c49f1e142c1932247a3
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 "base/memory/shared_memory.h"
16 #include "base/single_thread_task_runner.h"
17 #include "base/time/time.h"
18 #include "media/cast/cast_defines.h"
19 #include "media/cast/net/cast_transport_config.h"
21 namespace media {
22 class VideoEncodeAccelerator;
24 namespace cast {
26 // TODO(miu): Merge AudioSenderConfig and VideoSenderConfig and make their
27 // naming/documentation consistent with FrameReceiverConfig.
28 struct AudioSenderConfig {
29 AudioSenderConfig();
30 ~AudioSenderConfig();
32 // Identifier referring to the sender, used by the receiver.
33 uint32 ssrc;
35 // The receiver's SSRC identifier.
36 uint32 receiver_ssrc;
38 // The total amount of time between a frame's capture/recording on the sender
39 // and its playback on the receiver (i.e., shown to a user). This should be
40 // set to a value large enough to give the system sufficient time to encode,
41 // transmit/retransmit, receive, decode, and render; given its run-time
42 // environment (sender/receiver hardware performance, network conditions,
43 // etc.).
44 base::TimeDelta min_playout_delay;
45 base::TimeDelta max_playout_delay;
47 // RTP payload type enum: Specifies the type/encoding of frame data.
48 int rtp_payload_type;
50 bool use_external_encoder;
51 int frequency;
52 int channels;
53 int bitrate; // Set to <= 0 for "auto variable bitrate" (libopus knows best).
54 Codec codec;
56 // The AES crypto key and initialization vector. Each of these strings
57 // contains the data in binary form, of size kAesKeySize. If they are empty
58 // strings, crypto is not being used.
59 std::string aes_key;
60 std::string aes_iv_mask;
63 struct VideoSenderConfig {
64 VideoSenderConfig();
65 ~VideoSenderConfig();
67 // Identifier referring to the sender, used by the receiver.
68 uint32 ssrc;
70 // The receiver's SSRC identifier.
71 uint32 receiver_ssrc;
73 // The total amount of time between a frame's capture/recording on the sender
74 // and its playback on the receiver (i.e., shown to a user). This should be
75 // set to a value large enough to give the system sufficient time to encode,
76 // transmit/retransmit, receive, decode, and render; given its run-time
77 // environment (sender/receiver hardware performance, network conditions,
78 // etc.).
79 base::TimeDelta min_playout_delay;
80 base::TimeDelta max_playout_delay;
82 // RTP payload type enum: Specifies the type/encoding of frame data.
83 int rtp_payload_type;
85 bool use_external_encoder;
87 float congestion_control_back_off;
88 int max_bitrate;
89 int min_bitrate;
90 int start_bitrate;
91 int max_qp;
92 int min_qp;
93 int max_frame_rate; // TODO(miu): Should be double, not int.
95 // This field is used differently by various encoders. It defaults to 1.
97 // For VP8, it should be 1 to operate in single-buffer mode, or 3 to operate
98 // in multi-buffer mode. See
99 // http://www.webmproject.org/docs/encoder-parameters/ for details.
101 // For H.264 on Mac or iOS, it controls the max number of frames the encoder
102 // may hold before emitting a frame. A larger window may allow higher encoding
103 // efficiency at the cost of latency and memory. Set to 0 to let the encoder
104 // choose a suitable value for the platform and other encoding settings.
105 int max_number_of_video_buffers_used;
107 Codec codec;
108 int number_of_encode_threads;
110 // The AES crypto key and initialization vector. Each of these strings
111 // contains the data in binary form, of size kAesKeySize. If they are empty
112 // strings, crypto is not being used.
113 std::string aes_key;
114 std::string aes_iv_mask;
117 // TODO(miu): Naming and minor type changes are badly needed in a later CL.
118 struct FrameReceiverConfig {
119 FrameReceiverConfig();
120 ~FrameReceiverConfig();
122 // The receiver's SSRC identifier.
123 uint32 receiver_ssrc;
125 // The sender's SSRC identifier.
126 uint32 sender_ssrc;
128 // The total amount of time between a frame's capture/recording on the sender
129 // and its playback on the receiver (i.e., shown to a user). This is fixed as
130 // a value large enough to give the system sufficient time to encode,
131 // transmit/retransmit, receive, decode, and render; given its run-time
132 // environment (sender/receiver hardware performance, network conditions,
133 // etc.).
134 int rtp_max_delay_ms; // TODO(miu): Change to TimeDelta target_playout_delay.
136 // RTP payload type enum: Specifies the type/encoding of frame data.
137 int rtp_payload_type;
139 // RTP timebase: The number of RTP units advanced per one second. For audio,
140 // this is the sampling rate. For video, by convention, this is 90 kHz.
141 int rtp_timebase;
143 // Number of channels. For audio, this is normally 2. For video, this must
144 // be 1 as Cast does not have support for stereoscopic video.
145 int channels;
147 // The target frame rate. For audio, this is normally 100 (i.e., frames have
148 // a duration of 10ms each). For video, this is normally 30, but any frame
149 // rate is supported.
150 int target_frame_rate;
152 // Codec used for the compression of signal data.
153 // TODO(miu): Merge the AudioCodec and VideoCodec enums into one so this union
154 // is not necessary.
155 Codec codec;
157 // The AES crypto key and initialization vector. Each of these strings
158 // contains the data in binary form, of size kAesKeySize. If they are empty
159 // strings, crypto is not being used.
160 std::string aes_key;
161 std::string aes_iv_mask;
164 // Import from media::cast.
166 typedef Packet Packet;
167 typedef PacketList PacketList;
169 // Callback that is run to update the client with current status. This is used
170 // to allow the client to wait for asynchronous initialization to complete
171 // before sending frames, and also to be notified of any runtime errors that
172 // have halted the session.
173 typedef base::Callback<void(OperationalStatus)> StatusChangeCallback;
175 typedef base::Callback<void(scoped_refptr<base::SingleThreadTaskRunner>,
176 scoped_ptr<media::VideoEncodeAccelerator>)>
177 ReceiveVideoEncodeAcceleratorCallback;
178 typedef base::Callback<void(const ReceiveVideoEncodeAcceleratorCallback&)>
179 CreateVideoEncodeAcceleratorCallback;
181 typedef base::Callback<void(scoped_ptr<base::SharedMemory>)>
182 ReceiveVideoEncodeMemoryCallback;
183 typedef base::Callback<void(size_t size,
184 const ReceiveVideoEncodeMemoryCallback&)>
185 CreateVideoEncodeMemoryCallback;
187 } // namespace cast
188 } // namespace media
190 #endif // MEDIA_CAST_CAST_CONFIG_H_