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