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. 4 5 #ifndef MEDIA_CAST_CAST_CONFIG_H_ 6 #define MEDIA_CAST_CAST_CONFIG_H_ 7 8 #include <list> 9 #include <string> 10 #include <vector> 11 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" 20 21 namespace media { 22 class VideoEncodeAccelerator; 23 24 namespace cast { 25 26 // TODO(miu): Merge AudioSenderConfig and VideoSenderConfig and make their 27 // naming/documentation consistent with FrameReceiverConfig. 28 struct AudioSenderConfig { 29 AudioSenderConfig(); 30 ~AudioSenderConfig(); 31 32 // Identifier referring to the sender, used by the receiver. 33 uint32 ssrc; 34 35 // The receiver's SSRC identifier. 36 uint32 incoming_feedback_ssrc; 37 38 int rtcp_interval; 39 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; 48 49 // RTP payload type enum: Specifies the type/encoding of frame data. 50 int rtp_payload_type; 51 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; 57 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; 63 }; 64 65 struct VideoSenderConfig { 66 VideoSenderConfig(); 67 ~VideoSenderConfig(); 68 69 // Identifier referring to the sender, used by the receiver. 70 uint32 ssrc; 71 72 // The receiver's SSRC identifier. 73 uint32 incoming_feedback_ssrc; // TODO(miu): Rename to receiver_ssrc. 74 75 int rtcp_interval; 76 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; 85 86 // RTP payload type enum: Specifies the type/encoding of frame data. 87 int rtp_payload_type; 88 89 bool use_external_encoder; 90 int width; // Incoming frames will be scaled to this size. 91 int height; 92 93 float congestion_control_back_off; 94 int max_bitrate; 95 int min_bitrate; 96 int start_bitrate; 97 int max_qp; 98 int min_qp; 99 int max_frame_rate; // TODO(miu): Should be double, not int. 100 int max_number_of_video_buffers_used; // Max value depend on codec. 101 Codec codec; 102 int number_of_encode_threads; 103 104 // The AES crypto key and initialization vector. Each of these strings 105 // contains the data in binary form, of size kAesKeySize. If they are empty 106 // strings, crypto is not being used. 107 std::string aes_key; 108 std::string aes_iv_mask; 109 }; 110 111 // TODO(miu): Naming and minor type changes are badly needed in a later CL. 112 struct FrameReceiverConfig { 113 FrameReceiverConfig(); 114 ~FrameReceiverConfig(); 115 116 // The receiver's SSRC identifier. 117 uint32 feedback_ssrc; // TODO(miu): Rename to receiver_ssrc for clarity. 118 119 // The sender's SSRC identifier. 120 uint32 incoming_ssrc; // TODO(miu): Rename to sender_ssrc for clarity. 121 122 // Mean interval (in milliseconds) between RTCP reports. 123 // TODO(miu): Remove this since it's never not kDefaultRtcpIntervalMs. 124 int rtcp_interval; 125 126 // The total amount of time between a frame's capture/recording on the sender 127 // and its playback on the receiver (i.e., shown to a user). This is fixed as 128 // a value large enough to give the system sufficient time to encode, 129 // transmit/retransmit, receive, decode, and render; given its run-time 130 // environment (sender/receiver hardware performance, network conditions, 131 // etc.). 132 int rtp_max_delay_ms; // TODO(miu): Change to TimeDelta target_playout_delay. 133 134 // RTP payload type enum: Specifies the type/encoding of frame data. 135 int rtp_payload_type; 136 137 // RTP timebase: The number of RTP units advanced per one second. For audio, 138 // this is the sampling rate. For video, by convention, this is 90 kHz. 139 int frequency; // TODO(miu): Rename to rtp_timebase for clarity. 140 141 // Number of channels. For audio, this is normally 2. For video, this must 142 // be 1 as Cast does not have support for stereoscopic video. 143 int channels; 144 145 // The target frame rate. For audio, this is normally 100 (i.e., frames have 146 // a duration of 10ms each). For video, this is normally 30, but any frame 147 // rate is supported. 148 int max_frame_rate; // TODO(miu): Rename to target_frame_rate. 149 150 // Codec used for the compression of signal data. 151 // TODO(miu): Merge the AudioCodec and VideoCodec enums into one so this union 152 // is not necessary. 153 Codec codec; 154 155 // The AES crypto key and initialization vector. Each of these strings 156 // contains the data in binary form, of size kAesKeySize. If they are empty 157 // strings, crypto is not being used. 158 std::string aes_key; 159 std::string aes_iv_mask; 160 }; 161 162 // Import from media::cast. 163 164 typedef Packet Packet; 165 typedef PacketList PacketList; 166 167 typedef base::Callback<void(CastInitializationStatus)> 168 CastInitializationCallback; 169 170 typedef base::Callback<void(scoped_refptr<base::SingleThreadTaskRunner>, 171 scoped_ptr<media::VideoEncodeAccelerator>)> 172 ReceiveVideoEncodeAcceleratorCallback; 173 typedef base::Callback<void(const ReceiveVideoEncodeAcceleratorCallback&)> 174 CreateVideoEncodeAcceleratorCallback; 175 176 typedef base::Callback<void(scoped_ptr<base::SharedMemory>)> 177 ReceiveVideoEncodeMemoryCallback; 178 typedef base::Callback<void(size_t size, 179 const ReceiveVideoEncodeMemoryCallback&)> 180 CreateVideoEncodeMemoryCallback; 181 182 } // namespace cast 183 } // namespace media 184 185 #endif // MEDIA_CAST_CAST_CONFIG_H_ 186