OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 EXTENSIONS_RENDERER_API_DISPLAY_SOURCE_WIFI_DISPLAY_WIFI_DISPLAY_MEDIA_E
NCODER_H_ | 5 #ifndef EXTENSIONS_RENDERER_API_DISPLAY_SOURCE_WIFI_DISPLAY_WIFI_DISPLAY_MEDIA_E
NCODER_H_ |
6 #define EXTENSIONS_RENDERER_API_DISPLAY_SOURCE_WIFI_DISPLAY_WIFI_DISPLAY_MEDIA_E
NCODER_H_ | 6 #define EXTENSIONS_RENDERER_API_DISPLAY_SOURCE_WIFI_DISPLAY_WIFI_DISPLAY_MEDIA_E
NCODER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/move.h" | 14 #include "base/move.h" |
15 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
16 #include "base/threading/thread_checker.h" | 16 #include "base/threading/thread_checker.h" |
| 17 #include "extensions/renderer/api/display_source/wifi_display/wifi_display_eleme
ntary_stream_info.h" |
17 | 18 |
18 namespace extensions { | 19 namespace extensions { |
19 | 20 |
20 // This structure represents an encoded media unit such as a video frame or | 21 // This structure represents an encoded media unit such as a video frame or |
21 // a number of audio frames. | 22 // a number of audio frames. |
22 struct WiFiDisplayEncodedUnit { | 23 struct WiFiDisplayEncodedUnit { |
23 WiFiDisplayEncodedUnit(std::string data, | 24 WiFiDisplayEncodedUnit(std::string data, |
24 base::TimeTicks reference_timestamp, | 25 base::TimeTicks reference_timestamp, |
25 bool key_frame); | 26 bool key_frame); |
26 WiFiDisplayEncodedUnit(std::string data, | 27 WiFiDisplayEncodedUnit(std::string data, |
(...skipping 17 matching lines...) Expand all Loading... |
44 | 45 |
45 // This interface is a base class for audio and video encoders used by the | 46 // This interface is a base class for audio and video encoders used by the |
46 // Wi-Fi Display media pipeline. | 47 // Wi-Fi Display media pipeline. |
47 // Threading: the client code should belong to a single thread. | 48 // Threading: the client code should belong to a single thread. |
48 class WiFiDisplayMediaEncoder | 49 class WiFiDisplayMediaEncoder |
49 : public base::RefCountedThreadSafe<WiFiDisplayMediaEncoder> { | 50 : public base::RefCountedThreadSafe<WiFiDisplayMediaEncoder> { |
50 public: | 51 public: |
51 using EncodedUnitCallback = | 52 using EncodedUnitCallback = |
52 base::Callback<void(std::unique_ptr<WiFiDisplayEncodedUnit>)>; | 53 base::Callback<void(std::unique_ptr<WiFiDisplayEncodedUnit>)>; |
53 | 54 |
| 55 // Creates an elementary stream info describing the stream of encoded units |
| 56 // which this encoder generates and passes to a callback set using |
| 57 // |SetCallbacks|. The created elementary stream info should be passed to |
| 58 // a Wi-Fi Display media packetizer. |
| 59 virtual WiFiDisplayElementaryStreamInfo CreateElementaryStreamInfo() |
| 60 const = 0; |
| 61 |
54 // Sets callbacks for the obtained encoder instance: | 62 // Sets callbacks for the obtained encoder instance: |
55 // |encoded_callback| is invoked to return the next encoded unit | 63 // |encoded_callback| is invoked to return the next encoded unit |
56 // |error_callback| is invoked to report a fatal encoder error | 64 // |error_callback| is invoked to report a fatal encoder error |
57 void SetCallbacks(const EncodedUnitCallback& encoded_callback, | 65 void SetCallbacks(const EncodedUnitCallback& encoded_callback, |
58 const base::Closure& error_callback); | 66 const base::Closure& error_callback); |
59 | 67 |
60 protected: | 68 protected: |
61 friend class base::RefCountedThreadSafe<WiFiDisplayMediaEncoder>; | 69 friend class base::RefCountedThreadSafe<WiFiDisplayMediaEncoder>; |
62 | 70 |
63 WiFiDisplayMediaEncoder(); | 71 WiFiDisplayMediaEncoder(); |
64 virtual ~WiFiDisplayMediaEncoder(); | 72 virtual ~WiFiDisplayMediaEncoder(); |
65 | 73 |
66 base::ThreadChecker client_thread_checker_; | 74 base::ThreadChecker client_thread_checker_; |
67 EncodedUnitCallback encoded_callback_; | 75 EncodedUnitCallback encoded_callback_; |
68 base::Closure error_callback_; | 76 base::Closure error_callback_; |
69 }; | 77 }; |
70 | 78 |
71 } // namespace extensions | 79 } // namespace extensions |
72 | 80 |
73 #endif // EXTENSIONS_RENDERER_API_DISPLAY_SOURCE_WIFI_DISPLAY_WIFI_DISPLAY_MEDI
A_ENCODER_H_ | 81 #endif // EXTENSIONS_RENDERER_API_DISPLAY_SOURCE_WIFI_DISPLAY_WIFI_DISPLAY_MEDI
A_ENCODER_H_ |
OLD | NEW |