Unregister from GCM when the only GCM app is removed
[chromium-blink-merge.git] / media / cast / cast_config.h
blob9deb67805b68c1f8ce01f7f7a41419db52b1235c
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 int rtcp_interval;
40 // The total amount of time between a frame's capture/recording on the sender
41 // and its playback on the receiver (i.e., shown to a user). This should be
42 // set to a value large enough to give the system sufficient time to encode,
43 // transmit/retransmit, receive, decode, and render; given its run-time
44 // environment (sender/receiver hardware performance, network conditions,
45 // etc.).
46 base::TimeDelta min_playout_delay;
47 base::TimeDelta max_playout_delay;
49 // RTP payload type enum: Specifies the type/encoding of frame data.
50 int rtp_payload_type;
52 bool use_external_encoder;
53 int frequency;
54 int channels;
55 int bitrate; // Set to <= 0 for "auto variable bitrate" (libopus knows best).
56 Codec codec;
58 // The AES crypto key and initialization vector. Each of these strings
59 // contains the data in binary form, of size kAesKeySize. If they are empty
60 // strings, crypto is not being used.
61 std::string aes_key;
62 std::string aes_iv_mask;
65 struct VideoSenderConfig {
66 VideoSenderConfig();
67 ~VideoSenderConfig();
69 // Identifier referring to the sender, used by the receiver.
70 uint32 ssrc;
72 // The receiver's SSRC identifier.
73 uint32 receiver_ssrc;
75 int rtcp_interval;
77 // The total amount of time between a frame's capture/recording on the sender
78 // and its playback on the receiver (i.e., shown to a user). This should be
79 // set to a value large enough to give the system sufficient time to encode,
80 // transmit/retransmit, receive, decode, and render; given its run-time
81 // environment (sender/receiver hardware performance, network conditions,
82 // etc.).
83 base::TimeDelta min_playout_delay;
84 base::TimeDelta max_playout_delay;
86 // RTP payload type enum: Specifies the type/encoding of frame data.
87 int rtp_payload_type;
89 bool use_external_encoder;
91 float congestion_control_back_off;
92 int max_bitrate;
93 int min_bitrate;
94 int start_bitrate;
95 int max_qp;
96 int min_qp;
97 int max_frame_rate; // TODO(miu): Should be double, not int.
99 // This field is used differently by various encoders. It defaults to 1.
101 // For VP8, it should be 1 to operate in single-buffer mode, or 3 to operate
102 // in multi-buffer mode. See
103 // http://www.webmproject.org/docs/encoder-parameters/ for details.
105 // For H.264 on Mac or iOS, it controls the max number of frames the encoder
106 // may hold before emitting a frame. A larger window may allow higher encoding
107 // efficiency at the cost of latency and memory. Set to 0 to let the encoder
108 // choose a suitable value for the platform and other encoding settings.
109 int max_number_of_video_buffers_used;
111 Codec codec;
112 int number_of_encode_threads;
114 // The AES crypto key and initialization vector. Each of these strings
115 // contains the data in binary form, of size kAesKeySize. If they are empty
116 // strings, crypto is not being used.
117 std::string aes_key;
118 std::string aes_iv_mask;
121 // TODO(miu): Naming and minor type changes are badly needed in a later CL.
122 struct FrameReceiverConfig {
123 FrameReceiverConfig();
124 ~FrameReceiverConfig();
126 // The receiver's SSRC identifier.
127 uint32 feedback_ssrc; // TODO(miu): Rename to receiver_ssrc for clarity.
129 // The sender's SSRC identifier.
130 uint32 incoming_ssrc; // TODO(miu): Rename to sender_ssrc for clarity.
132 // Mean interval (in milliseconds) between RTCP reports.
133 // TODO(miu): Remove this since it's never not kDefaultRtcpIntervalMs.
134 int rtcp_interval;
136 // The total amount of time between a frame's capture/recording on the sender
137 // and its playback on the receiver (i.e., shown to a user). This is fixed as
138 // a value large enough to give the system sufficient time to encode,
139 // transmit/retransmit, receive, decode, and render; given its run-time
140 // environment (sender/receiver hardware performance, network conditions,
141 // etc.).
142 int rtp_max_delay_ms; // TODO(miu): Change to TimeDelta target_playout_delay.
144 // RTP payload type enum: Specifies the type/encoding of frame data.
145 int rtp_payload_type;
147 // RTP timebase: The number of RTP units advanced per one second. For audio,
148 // this is the sampling rate. For video, by convention, this is 90 kHz.
149 int rtp_timebase;
151 // Number of channels. For audio, this is normally 2. For video, this must
152 // be 1 as Cast does not have support for stereoscopic video.
153 int channels;
155 // The target frame rate. For audio, this is normally 100 (i.e., frames have
156 // a duration of 10ms each). For video, this is normally 30, but any frame
157 // rate is supported.
158 int target_frame_rate;
160 // Codec used for the compression of signal data.
161 // TODO(miu): Merge the AudioCodec and VideoCodec enums into one so this union
162 // is not necessary.
163 Codec codec;
165 // The AES crypto key and initialization vector. Each of these strings
166 // contains the data in binary form, of size kAesKeySize. If they are empty
167 // strings, crypto is not being used.
168 std::string aes_key;
169 std::string aes_iv_mask;
172 // Import from media::cast.
174 typedef Packet Packet;
175 typedef PacketList PacketList;
177 // Callback that is run to update the client with current status. This is used
178 // to allow the client to wait for asynchronous initialization to complete
179 // before sending frames, and also to be notified of any runtime errors that
180 // have halted the session.
181 typedef base::Callback<void(OperationalStatus)> StatusChangeCallback;
183 typedef base::Callback<void(scoped_refptr<base::SingleThreadTaskRunner>,
184 scoped_ptr<media::VideoEncodeAccelerator>)>
185 ReceiveVideoEncodeAcceleratorCallback;
186 typedef base::Callback<void(const ReceiveVideoEncodeAcceleratorCallback&)>
187 CreateVideoEncodeAcceleratorCallback;
189 typedef base::Callback<void(scoped_ptr<base::SharedMemory>)>
190 ReceiveVideoEncodeMemoryCallback;
191 typedef base::Callback<void(size_t size,
192 const ReceiveVideoEncodeMemoryCallback&)>
193 CreateVideoEncodeMemoryCallback;
195 } // namespace cast
196 } // namespace media
198 #endif // MEDIA_CAST_CAST_CONFIG_H_