OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 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_ |
| 7 |
| 8 #include <memory> |
| 9 #include <string> |
| 10 |
| 11 #include "base/callback.h" |
| 12 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/move.h" |
| 15 #include "base/single_thread_task_runner.h" |
| 16 |
| 17 namespace extensions { |
| 18 |
| 19 // This structure represents an encoded media unit such as a video frame or |
| 20 // a number of audio frames. |
| 21 struct WiFiDisplayEncodedUnit { |
| 22 WiFiDisplayEncodedUnit(std::string data, |
| 23 base::TimeTicks reference_timestamp, |
| 24 bool key_frame); |
| 25 WiFiDisplayEncodedUnit(std::string data, |
| 26 base::TimeTicks reference_timestamp, |
| 27 base::TimeTicks encode_timestamp, |
| 28 bool key_frame); |
| 29 |
| 30 const uint8_t* bytes() const { |
| 31 return reinterpret_cast<const uint8_t*>(data.data()); |
| 32 } |
| 33 size_t size() const { return data.size(); } |
| 34 |
| 35 std::string data; |
| 36 base::TimeTicks pts; // Presentation timestamp. |
| 37 base::TimeTicks dts; // Decoder timestamp. |
| 38 bool key_frame; |
| 39 |
| 40 DISALLOW_ASSIGN(WiFiDisplayEncodedUnit); |
| 41 DISALLOW_COPY(WiFiDisplayEncodedUnit); |
| 42 }; |
| 43 |
| 44 // This interface is a base class for audio and video encoders used by the |
| 45 // Wi-Fi Display media pipeline. |
| 46 // Threading: the client code should belong to a single thread. |
| 47 class WiFiDisplayMediaEncoder |
| 48 : public base::RefCountedThreadSafe<WiFiDisplayMediaEncoder> { |
| 49 public: |
| 50 using EncodedUnitCallback = |
| 51 base::Callback<void(std::unique_ptr<WiFiDisplayEncodedUnit>)>; |
| 52 |
| 53 // Sets callbacks for the obtained encoder instance: |
| 54 // |encoded_callback| is invoked to return the next encoded unit |
| 55 // |error_callback| is invoked to report a fatal encoder error |
| 56 void SetCallbacks(const EncodedUnitCallback& encoded_callback, |
| 57 const base::Closure& error_callback); |
| 58 |
| 59 protected: |
| 60 friend class base::RefCountedThreadSafe<WiFiDisplayMediaEncoder>; |
| 61 |
| 62 WiFiDisplayMediaEncoder(); |
| 63 virtual ~WiFiDisplayMediaEncoder(); |
| 64 |
| 65 EncodedUnitCallback encoded_callback_; |
| 66 base::Closure error_callback_; |
| 67 }; |
| 68 |
| 69 } // namespace extensions |
| 70 |
| 71 #endif // EXTENSIONS_RENDERER_API_DISPLAY_SOURCE_WIFI_DISPLAY_WIFI_DISPLAY_MEDI
A_ENCODER_H_ |
OLD | NEW |