Chromium Code Reviews| Index: extensions/renderer/api/display_source/wifi_display/wifi_display_media_encoder.h |
| diff --git a/extensions/renderer/api/display_source/wifi_display/wifi_display_media_encoder.h b/extensions/renderer/api/display_source/wifi_display/wifi_display_media_encoder.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..3a34a3b6804e280f6d6f3c9b69132b4433bceedf |
| --- /dev/null |
| +++ b/extensions/renderer/api/display_source/wifi_display/wifi_display_media_encoder.h |
| @@ -0,0 +1,69 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef EXTENSIONS_RENDERER_API_DISPLAY_SOURCE_WIFI_DISPLAY_WIFI_DISPLAY_MEDIA_ENCODER_H_ |
| +#define EXTENSIONS_RENDERER_API_DISPLAY_SOURCE_WIFI_DISPLAY_WIFI_DISPLAY_MEDIA_ENCODER_H_ |
| + |
| +#include <memory> |
| +#include <string> |
| + |
| +#include "base/callback.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "base/move.h" |
| +#include "base/single_thread_task_runner.h" |
| + |
| +namespace extensions { |
| + |
| +// This structure represents an encoded media unit such as a video frame or |
| +// a number of audio frames. |
| +struct WiFiDisplayEncodedUnit { |
| + public: |
|
Mikhail
2016/04/20 18:58:31
nit: 'public' is not needed in struct
e_hakkinen
2016/04/21 10:25:30
Done.
|
| + WiFiDisplayEncodedUnit(std::string data, |
| + base::TimeTicks reference_timestamp, |
| + bool key_frame); |
| + WiFiDisplayEncodedUnit(std::string data, |
| + base::TimeTicks reference_timestamp, |
| + base::TimeTicks encode_timestamp, |
| + bool key_frame); |
| + 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.
|
| + |
| + const uint8_t* bytes() const { |
| + return reinterpret_cast<const uint8_t*>(data.data()); |
| + } |
| + size_t size() const { return data.size(); } |
| + |
| + std::string data; |
| + base::TimeTicks pts; // Presentation timestamp. |
| + base::TimeTicks dts; // Decoder timestamp. |
| + bool key_frame; |
| +}; |
| + |
| +// This interface is a base class for audio and video encoders used by the |
| +// Wi-Fi Display media pipeline. |
| +// Threading: the client code should belong to a single thread. |
| +class WiFiDisplayMediaEncoder |
| + : public base::RefCountedThreadSafe<WiFiDisplayMediaEncoder> { |
| + public: |
| + using EncodedUnitCallback = |
| + base::Callback<void(std::unique_ptr<WiFiDisplayEncodedUnit>)>; |
| + |
| + // Sets callbacks for the obtained encoder instance: |
| + // |encoded_callback| is invoked to return the next encoded unit |
| + // |error_callback| is invoked to report a fatal encoder error |
| + void SetCallbacks(const EncodedUnitCallback& encoded_callback, |
| + const base::Closure& error_callback); |
| + |
| + protected: |
| + friend class base::RefCountedThreadSafe<WiFiDisplayMediaEncoder>; |
| + |
| + WiFiDisplayMediaEncoder(); |
| + virtual ~WiFiDisplayMediaEncoder(); |
| + |
| + EncodedUnitCallback encoded_callback_; |
| + base::Closure error_callback_; |
| +}; |
| + |
| +} // namespace extensions |
| + |
| +#endif // EXTENSIONS_RENDERER_API_DISPLAY_SOURCE_WIFI_DISPLAY_WIFI_DISPLAY_MEDIA_ENCODER_H_ |