| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #include "content/renderer/pepper/pepper_video_destination_host.h" | 5 #include "content/renderer/pepper/pepper_video_destination_host.h" |
| 6 | 6 |
| 7 #include "base/time/time.h" | 7 #include "base/time/time.h" |
| 8 #include "content/public/renderer/renderer_ppapi_host.h" | 8 #include "content/public/renderer/renderer_ppapi_host.h" |
| 9 #include "content/renderer/pepper/ppb_image_data_impl.h" | 9 #include "content/renderer/pepper/ppb_image_data_impl.h" |
| 10 #include "ppapi/c/pp_errors.h" | 10 #include "ppapi/c/pp_errors.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 PPB_ImageData_Impl* image_data_impl = | 75 PPB_ImageData_Impl* image_data_impl = |
| 76 static_cast<PPB_ImageData_Impl*>(enter.object()); | 76 static_cast<PPB_ImageData_Impl*>(enter.object()); |
| 77 | 77 |
| 78 if (!PPB_ImageData_Impl::IsImageDataFormatSupported( | 78 if (!PPB_ImageData_Impl::IsImageDataFormatSupported( |
| 79 image_data_impl->format())) | 79 image_data_impl->format())) |
| 80 return PP_ERROR_BADARGUMENT; | 80 return PP_ERROR_BADARGUMENT; |
| 81 | 81 |
| 82 if (!frame_writer_.get()) | 82 if (!frame_writer_.get()) |
| 83 return PP_ERROR_FAILED; | 83 return PP_ERROR_FAILED; |
| 84 | 84 |
| 85 // Convert PP_TimeTicks (a double, in seconds) to a video timestamp (int64, | 85 // Convert PP_TimeTicks (a double, in seconds) to a video timestamp (int64_t, |
| 86 // nanoseconds). | 86 // nanoseconds). |
| 87 const int64_t timestamp_ns = | 87 const int64_t timestamp_ns = |
| 88 static_cast<int64_t>(timestamp * base::Time::kNanosecondsPerSecond); | 88 static_cast<int64_t>(timestamp * base::Time::kNanosecondsPerSecond); |
| 89 // Check that timestamps are strictly increasing. | 89 // Check that timestamps are strictly increasing. |
| 90 #if DCHECK_IS_ON() | 90 #if DCHECK_IS_ON() |
| 91 if (has_received_frame_) | 91 if (has_received_frame_) |
| 92 DCHECK_GT(timestamp_ns, previous_timestamp_ns_); | 92 DCHECK_GT(timestamp_ns, previous_timestamp_ns_); |
| 93 has_received_frame_ = true; | 93 has_received_frame_ = true; |
| 94 previous_timestamp_ns_ = timestamp_ns; | 94 previous_timestamp_ns_ = timestamp_ns; |
| 95 #endif | 95 #endif |
| 96 | 96 |
| 97 frame_writer_->PutFrame(image_data_impl, timestamp_ns); | 97 frame_writer_->PutFrame(image_data_impl, timestamp_ns); |
| 98 | 98 |
| 99 return PP_OK; | 99 return PP_OK; |
| 100 } | 100 } |
| 101 | 101 |
| 102 int32_t PepperVideoDestinationHost::OnHostMsgClose( | 102 int32_t PepperVideoDestinationHost::OnHostMsgClose( |
| 103 HostMessageContext* context) { | 103 HostMessageContext* context) { |
| 104 frame_writer_.reset(NULL); | 104 frame_writer_.reset(NULL); |
| 105 return PP_OK; | 105 return PP_OK; |
| 106 } | 106 } |
| 107 | 107 |
| 108 } // namespace content | 108 } // namespace content |
| OLD | NEW |