Commit 196775ff authored by Guido Urdaneta's avatar Guido Urdaneta Committed by Commit Bot

[RTCInsertableStreams] Always sync JS ArrayBuffer with internal buffer.

It is possible to modify the data field without replacing it, so syncing
always where both a delegate frame and JS buffer exist.
Drive-by: handle cases with no delegate in other methods.

Bug: 1052765
Change-Id: I4cc1383b584d9d9f4334e0da1b6d7c092f94821d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2084855Reviewed-by: default avatarHarald Alvestrand <hta@chromium.org>
Commit-Queue: Guido Urdaneta <guidou@chromium.org>
Cr-Commit-Position: refs/heads/master@{#746494}
parent 2f33ed38
...@@ -25,7 +25,7 @@ String RTCEncodedVideoFrame::type() const { ...@@ -25,7 +25,7 @@ String RTCEncodedVideoFrame::type() const {
} }
uint64_t RTCEncodedVideoFrame::timestamp() const { uint64_t RTCEncodedVideoFrame::timestamp() const {
return delegate_->ReceivedTime(); return delegate_ ? delegate_->ReceivedTime() : 0;
} }
DOMArrayBuffer* RTCEncodedVideoFrame::data() const { DOMArrayBuffer* RTCEncodedVideoFrame::data() const {
...@@ -46,7 +46,6 @@ DOMArrayBuffer* RTCEncodedVideoFrame::additionalData() const { ...@@ -46,7 +46,6 @@ DOMArrayBuffer* RTCEncodedVideoFrame::additionalData() const {
void RTCEncodedVideoFrame::setData(DOMArrayBuffer* data) { void RTCEncodedVideoFrame::setData(DOMArrayBuffer* data) {
frame_data_ = data; frame_data_ = data;
replaced_frame_data_ = true;
} }
String RTCEncodedVideoFrame::toString() const { String RTCEncodedVideoFrame::toString() const {
...@@ -67,7 +66,7 @@ String RTCEncodedVideoFrame::toString() const { ...@@ -67,7 +66,7 @@ String RTCEncodedVideoFrame::toString() const {
std::unique_ptr<webrtc::video_coding::EncodedFrame> std::unique_ptr<webrtc::video_coding::EncodedFrame>
RTCEncodedVideoFrame::PassDelegate() { RTCEncodedVideoFrame::PassDelegate() {
// Sync the delegate data with |frame_data_| if necessary. // Sync the delegate data with |frame_data_| if necessary.
if (replaced_frame_data_) { if (delegate_ && frame_data_) {
rtc::scoped_refptr<webrtc::EncodedImageBuffer> webrtc_image = rtc::scoped_refptr<webrtc::EncodedImageBuffer> webrtc_image =
webrtc::EncodedImageBuffer::Create( webrtc::EncodedImageBuffer::Create(
static_cast<const uint8_t*>(frame_data_->Data()), static_cast<const uint8_t*>(frame_data_->Data()),
......
...@@ -52,7 +52,6 @@ class MODULES_EXPORT RTCEncodedVideoFrame final : public ScriptWrappable { ...@@ -52,7 +52,6 @@ class MODULES_EXPORT RTCEncodedVideoFrame final : public ScriptWrappable {
private: private:
std::unique_ptr<webrtc::video_coding::EncodedFrame> delegate_; std::unique_ptr<webrtc::video_coding::EncodedFrame> delegate_;
std::vector<uint8_t> additional_data_vector_; std::vector<uint8_t> additional_data_vector_;
bool replaced_frame_data_ = false;
// Exposes encoded frame data from |delegate_|. // Exposes encoded frame data from |delegate_|.
mutable Member<DOMArrayBuffer> frame_data_; mutable Member<DOMArrayBuffer> frame_data_;
// Exposes data from |additional_data_vector_|. // Exposes data from |additional_data_vector_|.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment