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_SESSION_H_ | 5 #ifndef CHROME_RENDERER_MEDIA_CAST_SESSION_H_ |
6 #define CHROME_RENDERER_MEDIA_CAST_SESSION_H_ | 6 #define CHROME_RENDERER_MEDIA_CAST_SESSION_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 21 matching lines...) Expand all Loading... |
32 class P2PSocketClient; | 32 class P2PSocketClient; |
33 } // namespace content | 33 } // namespace content |
34 | 34 |
35 class CastSessionDelegate; | 35 class CastSessionDelegate; |
36 | 36 |
37 // This class represents a Cast session and allows the session to be | 37 // This class represents a Cast session and allows the session to be |
38 // configured on the main thread. Actual work is forwarded to | 38 // configured on the main thread. Actual work is forwarded to |
39 // CastSessionDelegate on the IO thread. | 39 // CastSessionDelegate on the IO thread. |
40 class CastSession : public base::RefCounted<CastSession> { | 40 class CastSession : public base::RefCounted<CastSession> { |
41 public: | 41 public: |
42 typedef base::Callback<void(const scoped_refptr< | 42 using AudioFrameInputAvailableCallback = |
43 media::cast::AudioFrameInput>&)> AudioFrameInputAvailableCallback; | 43 base::Callback<void(const scoped_refptr<media::cast::AudioFrameInput>&)>; |
44 typedef base::Callback<void(const scoped_refptr< | 44 using VideoFrameInputAvailableCallback = |
45 media::cast::VideoFrameInput>&)> VideoFrameInputAvailableCallback; | 45 base::Callback<void(const scoped_refptr<media::cast::VideoFrameInput>&)>; |
46 typedef base::Callback<void(const std::vector<char>&)> SendPacketCallback; | 46 using SendPacketCallback = base::Callback<void(const std::vector<char>&)>; |
47 typedef base::Callback<void(std::unique_ptr<base::BinaryValue>)> | 47 using EventLogsCallback = |
48 EventLogsCallback; | 48 base::Callback<void(std::unique_ptr<base::BinaryValue>)>; |
49 typedef base::Callback<void(std::unique_ptr<base::DictionaryValue>)> | 49 using StatsCallback = |
50 StatsCallback; | 50 base::Callback<void(std::unique_ptr<base::DictionaryValue>)>; |
51 typedef base::Callback<void(const std::string&)> ErrorCallback; | 51 using ErrorCallback = base::Callback<void(const std::string&)>; |
52 | 52 |
53 CastSession(); | 53 CastSession(); |
54 | 54 |
55 // Start encoding of audio and video using the provided configuration. | 55 // Start encoding of audio and video using the provided configuration. |
56 // | 56 // |
57 // When Cast sender is started and ready to be used | 57 // When Cast sender is started and ready to be used |
58 // media::cast::FrameInput will be given through |callback|. | 58 // media::cast::FrameInput will be given through |callback|. |
59 // If it encounters an error, |error_callback| will be invoked with the | 59 // If it encounters an error, |error_callback| will be invoked with the |
60 // error message. Both |callback| and |error_callback| will be made on | 60 // error message. Both |callback| and |error_callback| will be made on |
61 // the main thread. | 61 // the main thread. |
62 // |StartUDP()| must be called before these methods. | 62 // |StartUDP()| must be called before these methods. |
63 void StartAudio(const media::cast::FrameSenderConfig& config, | 63 void StartAudio(const media::cast::FrameSenderConfig& config, |
64 const AudioFrameInputAvailableCallback& callback, | 64 const AudioFrameInputAvailableCallback& callback, |
65 const ErrorCallback& error_callback); | 65 const ErrorCallback& error_callback); |
66 void StartVideo(const media::cast::FrameSenderConfig& config, | 66 void StartVideo(const media::cast::FrameSenderConfig& config, |
67 const VideoFrameInputAvailableCallback& callback, | 67 const VideoFrameInputAvailableCallback& callback, |
68 const ErrorCallback& error_callback); | 68 const ErrorCallback& error_callback); |
69 | 69 |
| 70 // Start remoting a stream. |error_callback| will be invoked when any error |
| 71 // occurs. |StartUDP()| must be called before calling this method. |
| 72 void StartRemotingStream(int32_t stream_id, |
| 73 const media::cast::FrameSenderConfig& config, |
| 74 const ErrorCallback& error_callback); |
| 75 |
70 // This will create the Cast transport and connect to |remote_endpoint|. | 76 // This will create the Cast transport and connect to |remote_endpoint|. |
71 // |options| is a dictionary which contain optional configuration for the | 77 // |options| is a dictionary which contain optional configuration for the |
72 // udp transport. | 78 // udp transport. |
73 // Must be called before initialization of audio or video. | 79 // Must be called before initialization of audio or video. |
74 void StartUDP(const net::IPEndPoint& remote_endpoint, | 80 void StartUDP(const net::IPEndPoint& remote_endpoint, |
75 std::unique_ptr<base::DictionaryValue> options, | 81 std::unique_ptr<base::DictionaryValue> options, |
76 const ErrorCallback& error_callback); | 82 const ErrorCallback& error_callback); |
77 | 83 |
78 // Creates or destroys event subscriber for the audio or video stream. | 84 // Creates or destroys event subscriber for the audio or video stream. |
79 // |is_audio|: true if the event subscriber is for audio. Video otherwise. | 85 // |is_audio|: true if the event subscriber is for audio. Video otherwise. |
(...skipping 21 matching lines...) Expand all Loading... |
101 // because it is owned by this object. | 107 // because it is owned by this object. |
102 std::unique_ptr<CastSessionDelegate> delegate_; | 108 std::unique_ptr<CastSessionDelegate> delegate_; |
103 | 109 |
104 // Proxy to the IO task runner. | 110 // Proxy to the IO task runner. |
105 const scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | 111 const scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
106 | 112 |
107 DISALLOW_COPY_AND_ASSIGN(CastSession); | 113 DISALLOW_COPY_AND_ASSIGN(CastSession); |
108 }; | 114 }; |
109 | 115 |
110 #endif // CHROME_RENDERER_MEDIA_CAST_SESSION_H_ | 116 #endif // CHROME_RENDERER_MEDIA_CAST_SESSION_H_ |
OLD | NEW |