| 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> |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 class CastRtpStream { | 34 class CastRtpStream { |
| 35 public: | 35 public: |
| 36 typedef base::Callback<void(const std::string&)> ErrorCallback; | 36 typedef base::Callback<void(const std::string&)> ErrorCallback; |
| 37 | 37 |
| 38 static bool IsHardwareVP8EncodingSupported(); | 38 static bool IsHardwareVP8EncodingSupported(); |
| 39 | 39 |
| 40 static bool IsHardwareH264EncodingSupported(); | 40 static bool IsHardwareH264EncodingSupported(); |
| 41 | 41 |
| 42 CastRtpStream(const blink::WebMediaStreamTrack& track, | 42 CastRtpStream(const blink::WebMediaStreamTrack& track, |
| 43 const scoped_refptr<CastSession>& session); | 43 const scoped_refptr<CastSession>& session); |
| 44 CastRtpStream(bool is_audio, const scoped_refptr<CastSession>& session); |
| 44 ~CastRtpStream(); | 45 ~CastRtpStream(); |
| 45 | 46 |
| 46 // Return parameters currently supported by this stream. | 47 // Return parameters currently supported by this stream. |
| 47 std::vector<media::cast::FrameSenderConfig> GetSupportedConfigs(); | 48 std::vector<media::cast::FrameSenderConfig> GetSupportedConfigs(); |
| 48 | 49 |
| 49 // Begin encoding of media stream and then submit the encoded streams | 50 // Begin encoding of media stream and then submit the encoded streams |
| 50 // to underlying transport. | 51 // to underlying transport. |
| 52 // |stream_id| is the unique ID of this stream. |
| 51 // When the stream is started |start_callback| is called. | 53 // When the stream is started |start_callback| is called. |
| 52 // When the stream is stopped |stop_callback| is called. | 54 // When the stream is stopped |stop_callback| is called. |
| 53 // When there is an error |error_callback| is called with a message. | 55 // When there is an error |error_callback| is called with a message. |
| 54 void Start(const media::cast::FrameSenderConfig& config, | 56 void Start(int32_t stream_id, |
| 57 const media::cast::FrameSenderConfig& config, |
| 55 const base::Closure& start_callback, | 58 const base::Closure& start_callback, |
| 56 const base::Closure& stop_callback, | 59 const base::Closure& stop_callback, |
| 57 const ErrorCallback& error_callback); | 60 const ErrorCallback& error_callback); |
| 58 | 61 |
| 59 // Stop encoding. | 62 // Stop encoding. |
| 60 void Stop(); | 63 void Stop(); |
| 61 | 64 |
| 62 // Enables or disables logging for this stream. | 65 // Enables or disables logging for this stream. |
| 63 void ToggleLogging(bool enable); | 66 void ToggleLogging(bool enable); |
| 64 | 67 |
| 65 // Get serialized raw events for this stream with |extra_data| attached, | 68 // Get serialized raw events for this stream with |extra_data| attached, |
| 66 // and invokes |callback| with the result. | 69 // and invokes |callback| with the result. |
| 67 void GetRawEvents( | 70 void GetRawEvents( |
| 68 const base::Callback<void(std::unique_ptr<base::BinaryValue>)>& callback, | 71 const base::Callback<void(std::unique_ptr<base::BinaryValue>)>& callback, |
| 69 const std::string& extra_data); | 72 const std::string& extra_data); |
| 70 | 73 |
| 71 // Get stats in DictionaryValue format and invokves |callback| with | 74 // Get stats in DictionaryValue format and invokves |callback| with |
| 72 // the result. | 75 // the result. |
| 73 void GetStats(const base::Callback< | 76 void GetStats(const base::Callback< |
| 74 void(std::unique_ptr<base::DictionaryValue>)>& callback); | 77 void(std::unique_ptr<base::DictionaryValue>)>& callback); |
| 75 | 78 |
| 76 private: | 79 private: |
| 77 // Return true if this track is an audio track. Return false if this | |
| 78 // track is a video track. | |
| 79 bool IsAudio() const; | |
| 80 | |
| 81 void DidEncounterError(const std::string& message); | 80 void DidEncounterError(const std::string& message); |
| 82 | 81 |
| 83 blink::WebMediaStreamTrack track_; | 82 blink::WebMediaStreamTrack track_; |
| 84 const scoped_refptr<CastSession> cast_session_; | 83 const scoped_refptr<CastSession> cast_session_; |
| 85 std::unique_ptr<CastAudioSink> audio_sink_; | 84 std::unique_ptr<CastAudioSink> audio_sink_; |
| 86 std::unique_ptr<CastVideoSink> video_sink_; | 85 std::unique_ptr<CastVideoSink> video_sink_; |
| 87 base::Closure stop_callback_; | 86 base::Closure stop_callback_; |
| 88 ErrorCallback error_callback_; | 87 ErrorCallback error_callback_; |
| 88 bool is_audio_; |
| 89 | 89 |
| 90 base::WeakPtrFactory<CastRtpStream> weak_factory_; | 90 base::WeakPtrFactory<CastRtpStream> weak_factory_; |
| 91 | 91 |
| 92 DISALLOW_COPY_AND_ASSIGN(CastRtpStream); | 92 DISALLOW_COPY_AND_ASSIGN(CastRtpStream); |
| 93 }; | 93 }; |
| 94 | 94 |
| 95 #endif // CHROME_RENDERER_MEDIA_CAST_RTP_STREAM_H_ | 95 #endif // CHROME_RENDERER_MEDIA_CAST_RTP_STREAM_H_ |
| OLD | NEW |