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 #include "extensions/renderer/api/display_source/wifi_display/wifi_display_media
_encoder.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "media/base/bind_to_current_loop.h" |
| 9 |
| 10 namespace extensions { |
| 11 |
| 12 WiFiDisplayEncodedUnit::WiFiDisplayEncodedUnit( |
| 13 std::string data, |
| 14 base::TimeTicks reference_timestamp, |
| 15 bool key_frame) |
| 16 : data(std::move(data)), pts(reference_timestamp), key_frame(key_frame) {} |
| 17 |
| 18 WiFiDisplayEncodedUnit::WiFiDisplayEncodedUnit( |
| 19 std::string data, |
| 20 base::TimeTicks reference_timestamp, |
| 21 base::TimeTicks encode_timestamp, |
| 22 bool key_frame) |
| 23 : WiFiDisplayEncodedUnit(std::move(data), reference_timestamp, key_frame) { |
| 24 if (encode_timestamp >= reference_timestamp) { |
| 25 dts = reference_timestamp - (encode_timestamp - reference_timestamp); |
| 26 DCHECK_LE(dts, pts); |
| 27 } |
| 28 } |
| 29 |
| 30 WiFiDisplayMediaEncoder::WiFiDisplayMediaEncoder() = default; |
| 31 WiFiDisplayMediaEncoder::~WiFiDisplayMediaEncoder() = default; |
| 32 |
| 33 void WiFiDisplayMediaEncoder::SetCallbacks( |
| 34 const EncodedUnitCallback& encoded_callback, |
| 35 const base::Closure& error_callback) { |
| 36 // This is not thread-safe if encoding has been started thus allow |
| 37 // this to be called only once. |
| 38 DCHECK(encoded_callback_.is_null() && error_callback_.is_null()); |
| 39 encoded_callback_ = media::BindToCurrentLoop(encoded_callback); |
| 40 error_callback_ = media::BindToCurrentLoop(error_callback); |
| 41 } |
| 42 |
| 43 } // namespace extensions |
OLD | NEW |