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 | |
109 // This object represents a RTP stream that encodes and optionally | 29 // This object represents a RTP stream that encodes and optionally |
110 // encrypt audio or video data from a WebMediaStreamTrack. | 30 // encrypt audio or video data from a WebMediaStreamTrack. |
111 // Note that this object does not actually output packets. It allows | 31 // Note that this object does not actually output packets. It allows |
112 // configuration of encoding and RTP parameters and control such a logical | 32 // configuration of encoding and RTP parameters and control such a logical |
113 // stream. | 33 // stream. |
114 class CastRtpStream { | 34 class CastRtpStream { |
115 public: | 35 public: |
116 typedef base::Callback<void(const std::string&)> ErrorCallback; | 36 typedef base::Callback<void(const std::string&)> ErrorCallback; |
117 | 37 |
| 38 static bool IsHardwareVP8EncodingSupported(); |
| 39 |
| 40 static bool IsHardwareH264EncodingSupported(); |
| 41 |
118 CastRtpStream(const blink::WebMediaStreamTrack& track, | 42 CastRtpStream(const blink::WebMediaStreamTrack& track, |
119 const scoped_refptr<CastSession>& session); | 43 const scoped_refptr<CastSession>& session); |
120 ~CastRtpStream(); | 44 ~CastRtpStream(); |
121 | 45 |
122 // Return parameters currently supported by this stream. | 46 // Return parameters currently supported by this stream. |
123 std::vector<CastRtpParams> GetSupportedParams(); | 47 std::vector<media::cast::FrameSenderConfig> GetSupportedConfigs(); |
124 | |
125 // Return parameters set to this stream. | |
126 CastRtpParams GetParams(); | |
127 | 48 |
128 // Begin encoding of media stream and then submit the encoded streams | 49 // Begin encoding of media stream and then submit the encoded streams |
129 // to underlying transport. | 50 // to underlying transport. |
130 // When the stream is started |start_callback| is called. | 51 // When the stream is started |start_callback| is called. |
131 // When the stream is stopped |stop_callback| is called. | 52 // When the stream is stopped |stop_callback| is called. |
132 // 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. |
133 void Start(const CastRtpParams& params, | 54 void Start(const media::cast::FrameSenderConfig& config, |
134 const base::Closure& start_callback, | 55 const base::Closure& start_callback, |
135 const base::Closure& stop_callback, | 56 const base::Closure& stop_callback, |
136 const ErrorCallback& error_callback); | 57 const ErrorCallback& error_callback); |
137 | 58 |
138 // Stop encoding. | 59 // Stop encoding. |
139 void Stop(); | 60 void Stop(); |
140 | 61 |
141 // Enables or disables logging for this stream. | 62 // Enables or disables logging for this stream. |
142 void ToggleLogging(bool enable); | 63 void ToggleLogging(bool enable); |
143 | 64 |
(...skipping 12 matching lines...) Expand all Loading... |
156 // 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 |
157 // track is a video track. | 78 // track is a video track. |
158 bool IsAudio() const; | 79 bool IsAudio() const; |
159 | 80 |
160 void DidEncounterError(const std::string& message); | 81 void DidEncounterError(const std::string& message); |
161 | 82 |
162 blink::WebMediaStreamTrack track_; | 83 blink::WebMediaStreamTrack track_; |
163 const scoped_refptr<CastSession> cast_session_; | 84 const scoped_refptr<CastSession> cast_session_; |
164 std::unique_ptr<CastAudioSink> audio_sink_; | 85 std::unique_ptr<CastAudioSink> audio_sink_; |
165 std::unique_ptr<CastVideoSink> video_sink_; | 86 std::unique_ptr<CastVideoSink> video_sink_; |
166 CastRtpParams params_; | |
167 base::Closure stop_callback_; | 87 base::Closure stop_callback_; |
168 ErrorCallback error_callback_; | 88 ErrorCallback error_callback_; |
169 | 89 |
170 base::WeakPtrFactory<CastRtpStream> weak_factory_; | 90 base::WeakPtrFactory<CastRtpStream> weak_factory_; |
171 | 91 |
172 DISALLOW_COPY_AND_ASSIGN(CastRtpStream); | 92 DISALLOW_COPY_AND_ASSIGN(CastRtpStream); |
173 }; | 93 }; |
174 | 94 |
175 #endif // CHROME_RENDERER_MEDIA_CAST_RTP_STREAM_H_ | 95 #endif // CHROME_RENDERER_MEDIA_CAST_RTP_STREAM_H_ |
OLD | NEW |