Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_RENDERER_MEDIA_CAST_RTP_STREAM_H_ | 5 #ifndef CHROME_RENDERER_MEDIA_CAST_RTP_STREAM_H_ |
| 6 #define CHROME_RENDERER_MEDIA_CAST_RTP_STREAM_H_ | 6 #define CHROME_RENDERER_MEDIA_CAST_RTP_STREAM_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "media/cast/cast_config.h" | 16 #include "media/cast/cast_config.h" |
| 17 #include "media/cast/constants.h" | 17 #include "media/cast/constants.h" |
| 18 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" | 18 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" |
| 19 | 19 |
| 20 namespace base { | 20 namespace base { |
| 21 class BinaryValue; | 21 class BinaryValue; |
| 22 class DictionaryValue; | 22 class DictionaryValue; |
| 23 } | 23 } |
| 24 | 24 |
| 25 class CastAudioSink; | 25 class CastAudioSink; |
| 26 class CastSession; | 26 class CastSession; |
| 27 class CastVideoSink; | 27 class CastVideoSink; |
| 28 | 28 |
| 29 // A key value pair structure for codec specific parameters. | |
| 30 struct CastCodecSpecificParams { | |
| 31 std::string key; | |
| 32 std::string value; | |
| 33 | |
| 34 CastCodecSpecificParams(); | |
| 35 ~CastCodecSpecificParams(); | |
| 36 }; | |
| 37 | |
| 38 // Defines the basic properties of a payload supported by cast transport. | |
| 39 struct CastRtpPayloadParams { | |
|
miu
2016/06/30 21:59:43
Nice! :)
xjz
2016/07/01 23:52:09
:)
| |
| 40 // RTP specific field that identifies the content type. | |
| 41 int payload_type = media::cast::kDefaultRtpVideoPayloadType; | |
| 42 | |
| 43 // Maximum latency in milliseconds. Implemetation tries to keep latency | |
| 44 // under this threshold. | |
| 45 int max_latency_ms = media::cast::kDefaultRtpMaxDelayMs; | |
| 46 | |
| 47 // Minimum latency. | |
| 48 // Default value (0) means use max_latency_ms. | |
| 49 int min_latency_ms = 0; | |
| 50 | |
| 51 // Starting latency on animated content. | |
| 52 // Default value (0) means use max_latency_ms. | |
| 53 int animated_latency_ms = 0; | |
| 54 | |
| 55 // RTP specific field to identify a stream. | |
| 56 int ssrc = 1; | |
| 57 | |
| 58 // RTP specific field to idenfity the feedback stream. | |
| 59 int feedback_ssrc = 2; | |
| 60 | |
| 61 // Update frequency of payload sample. | |
| 62 int clock_rate = media::cast::kVideoFrequency; | |
| 63 | |
| 64 // Maximum bitrate in kilobits per second. | |
| 65 int max_bitrate = media::cast::kDefaultMaxVideoKbps; | |
| 66 | |
| 67 // Minimum bitrate in kilobits per second. | |
| 68 int min_bitrate = media::cast::kDefaultMinVideoKbps; | |
| 69 | |
| 70 // Number of audio channels. | |
| 71 int channels = 1; | |
| 72 | |
| 73 // The maximum frame rate. | |
| 74 double max_frame_rate = media::cast::kDefaultMaxFrameRate; | |
| 75 | |
| 76 // Name of the codec used. | |
| 77 std::string codec_name; | |
| 78 | |
| 79 // AES encryption key. | |
| 80 std::string aes_key; | |
| 81 | |
| 82 // AES encryption IV mask. | |
| 83 std::string aes_iv_mask; | |
| 84 | |
| 85 // List of codec specific parameters. | |
| 86 std::vector<CastCodecSpecificParams> codec_specific_params; | |
| 87 | |
| 88 CastRtpPayloadParams(); | |
| 89 CastRtpPayloadParams(const CastRtpPayloadParams& other); | |
| 90 ~CastRtpPayloadParams(); | |
| 91 }; | |
| 92 | |
| 93 // Defines the parameters of a RTP stream. | |
| 94 struct CastRtpParams { | |
| 95 explicit CastRtpParams(const CastRtpPayloadParams& payload_params); | |
| 96 | |
| 97 // Payload parameters. | |
| 98 CastRtpPayloadParams payload; | |
| 99 | |
| 100 // Names of supported RTCP features. | |
| 101 std::vector<std::string> rtcp_features; | |
| 102 | |
| 103 CastRtpParams(); | |
| 104 CastRtpParams(const CastRtpParams& other); | |
| 105 ~CastRtpParams(); | |
| 106 }; | |
| 107 | |
| 108 // This object represents a RTP stream that encodes and optionally | 29 // This object represents a RTP stream that encodes and optionally |
| 109 // encrypt audio or video data from a WebMediaStreamTrack. | 30 // encrypt audio or video data from a WebMediaStreamTrack. |
| 110 // Note that this object does not actually output packets. It allows | 31 // Note that this object does not actually output packets. It allows |
| 111 // configuration of encoding and RTP parameters and control such a logical | 32 // configuration of encoding and RTP parameters and control such a logical |
| 112 // stream. | 33 // stream. |
| 113 class CastRtpStream { | 34 class CastRtpStream { |
| 114 public: | 35 public: |
| 115 typedef base::Callback<void(const std::string&)> ErrorCallback; | 36 typedef base::Callback<void(const std::string&)> ErrorCallback; |
| 116 | 37 |
| 38 static bool IsHardwareVP8EncodingSupported(); | |
| 39 | |
| 40 static bool IsHardwareH264EncodingSupported(); | |
| 41 | |
| 117 CastRtpStream(const blink::WebMediaStreamTrack& track, | 42 CastRtpStream(const blink::WebMediaStreamTrack& track, |
| 118 const scoped_refptr<CastSession>& session); | 43 const scoped_refptr<CastSession>& session); |
| 119 ~CastRtpStream(); | 44 ~CastRtpStream(); |
| 120 | 45 |
| 121 // Return parameters currently supported by this stream. | 46 // Return parameters currently supported by this stream. |
| 122 std::vector<CastRtpParams> GetSupportedParams(); | 47 std::vector<media::cast::FrameSenderConfig> GetSupportedConfigs(); |
| 123 | |
| 124 // Return parameters set to this stream. | |
| 125 CastRtpParams GetParams(); | |
| 126 | 48 |
| 127 // Begin encoding of media stream and then submit the encoded streams | 49 // Begin encoding of media stream and then submit the encoded streams |
| 128 // to underlying transport. | 50 // to underlying transport. |
| 129 // When the stream is started |start_callback| is called. | 51 // When the stream is started |start_callback| is called. |
| 130 // When the stream is stopped |stop_callback| is called. | 52 // When the stream is stopped |stop_callback| is called. |
| 131 // When there is an error |error_callback| is called with a message. | 53 // When there is an error |error_callback| is called with a message. |
| 132 void Start(const CastRtpParams& params, | 54 void Start(const media::cast::FrameSenderConfig& config, |
| 133 const base::Closure& start_callback, | 55 const base::Closure& start_callback, |
| 134 const base::Closure& stop_callback, | 56 const base::Closure& stop_callback, |
| 135 const ErrorCallback& error_callback); | 57 const ErrorCallback& error_callback); |
| 136 | 58 |
| 137 // Stop encoding. | 59 // Stop encoding. |
| 138 void Stop(); | 60 void Stop(); |
| 139 | 61 |
| 140 // Enables or disables logging for this stream. | 62 // Enables or disables logging for this stream. |
| 141 void ToggleLogging(bool enable); | 63 void ToggleLogging(bool enable); |
| 142 | 64 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 155 // Return true if this track is an audio track. Return false if this | 77 // Return true if this track is an audio track. Return false if this |
| 156 // track is a video track. | 78 // track is a video track. |
| 157 bool IsAudio() const; | 79 bool IsAudio() const; |
| 158 | 80 |
| 159 void DidEncounterError(const std::string& message); | 81 void DidEncounterError(const std::string& message); |
| 160 | 82 |
| 161 blink::WebMediaStreamTrack track_; | 83 blink::WebMediaStreamTrack track_; |
| 162 const scoped_refptr<CastSession> cast_session_; | 84 const scoped_refptr<CastSession> cast_session_; |
| 163 std::unique_ptr<CastAudioSink> audio_sink_; | 85 std::unique_ptr<CastAudioSink> audio_sink_; |
| 164 std::unique_ptr<CastVideoSink> video_sink_; | 86 std::unique_ptr<CastVideoSink> video_sink_; |
| 165 CastRtpParams params_; | |
| 166 base::Closure stop_callback_; | 87 base::Closure stop_callback_; |
| 167 ErrorCallback error_callback_; | 88 ErrorCallback error_callback_; |
| 168 | 89 |
| 169 base::WeakPtrFactory<CastRtpStream> weak_factory_; | 90 base::WeakPtrFactory<CastRtpStream> weak_factory_; |
| 170 | 91 |
| 171 DISALLOW_COPY_AND_ASSIGN(CastRtpStream); | 92 DISALLOW_COPY_AND_ASSIGN(CastRtpStream); |
| 172 }; | 93 }; |
| 173 | 94 |
| 174 #endif // CHROME_RENDERER_MEDIA_CAST_RTP_STREAM_H_ | 95 #endif // CHROME_RENDERER_MEDIA_CAST_RTP_STREAM_H_ |
| OLD | NEW |