Chromium Code Reviews| 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/memory/ref_counted.h" | |
| 13 #include "base/move.h" | |
| 14 #include "base/single_thread_task_runner.h" | |
| 15 | |
| 16 namespace extensions { | |
| 17 | |
| 18 // This structure represents an encoded media unit such as a video frame or | |
| 19 // a number of audio frames. | |
| 20 struct WiFiDisplayEncodedUnit { | |
| 21 public: | |
|
Mikhail
2016/04/20 18:58:31
nit: 'public' is not needed in struct
e_hakkinen
2016/04/21 10:25:30
Done.
| |
| 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 WiFiDisplayEncodedUnit(const WiFiDisplayEncodedUnit&) = delete; | |
|
Mikhail
2016/04/20 18:58:31
DISALLOW_COPY_AND_ASSIGN would be better
e_hakkinen
2016/04/20 19:22:53
IMHO, the problem with DISALLOW_COPY_AND_ASSIGN is
e_hakkinen
2016/04/21 10:25:30
I'll use DISALLOW_ASSIGN and DISALLOW_COPY.
| |
| 30 | |
| 31 const uint8_t* bytes() const { | |
| 32 return reinterpret_cast<const uint8_t*>(data.data()); | |
| 33 } | |
| 34 size_t size() const { return data.size(); } | |
| 35 | |
| 36 std::string data; | |
| 37 base::TimeTicks pts; // Presentation timestamp. | |
| 38 base::TimeTicks dts; // Decoder timestamp. | |
| 39 bool key_frame; | |
| 40 }; | |
| 41 | |
| 42 // This interface is a base class for audio and video encoders used by the | |
| 43 // Wi-Fi Display media pipeline. | |
| 44 // Threading: the client code should belong to a single thread. | |
| 45 class WiFiDisplayMediaEncoder | |
| 46 : public base::RefCountedThreadSafe<WiFiDisplayMediaEncoder> { | |
| 47 public: | |
| 48 using EncodedUnitCallback = | |
| 49 base::Callback<void(std::unique_ptr<WiFiDisplayEncodedUnit>)>; | |
| 50 | |
| 51 // Sets callbacks for the obtained encoder instance: | |
| 52 // |encoded_callback| is invoked to return the next encoded unit | |
| 53 // |error_callback| is invoked to report a fatal encoder error | |
| 54 void SetCallbacks(const EncodedUnitCallback& encoded_callback, | |
| 55 const base::Closure& error_callback); | |
| 56 | |
| 57 protected: | |
| 58 friend class base::RefCountedThreadSafe<WiFiDisplayMediaEncoder>; | |
| 59 | |
| 60 WiFiDisplayMediaEncoder(); | |
| 61 virtual ~WiFiDisplayMediaEncoder(); | |
| 62 | |
| 63 EncodedUnitCallback encoded_callback_; | |
| 64 base::Closure error_callback_; | |
| 65 }; | |
| 66 | |
| 67 } // namespace extensions | |
| 68 | |
| 69 #endif // EXTENSIONS_RENDERER_API_DISPLAY_SOURCE_WIFI_DISPLAY_WIFI_DISPLAY_MEDI A_ENCODER_H_ | |
| OLD | NEW |