Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Side by Side Diff: media/base/video_frame.cc

Issue 313623003: WIP: Option2: Android media: VideoFrame should not store so many sync points. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/base/video_frame.h ('k') | media/base/video_frame_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "media/base/video_frame.h" 5 #include "media/base/video_frame.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 timestamp_(timestamp), 597 timestamp_(timestamp),
598 end_of_stream_(end_of_stream) { 598 end_of_stream_(end_of_stream) {
599 DCHECK(IsValidConfig(format_, coded_size_, visible_rect_, natural_size_)); 599 DCHECK(IsValidConfig(format_, coded_size_, visible_rect_, natural_size_));
600 600
601 memset(&strides_, 0, sizeof(strides_)); 601 memset(&strides_, 0, sizeof(strides_));
602 memset(&data_, 0, sizeof(data_)); 602 memset(&data_, 0, sizeof(data_));
603 } 603 }
604 604
605 VideoFrame::~VideoFrame() { 605 VideoFrame::~VideoFrame() {
606 if (!mailbox_holder_release_cb_.is_null()) { 606 if (!mailbox_holder_release_cb_.is_null()) {
607 std::vector<uint32> release_sync_points; 607 std::map<std::string, uint32> release_sync_points;
608 { 608 {
609 base::AutoLock locker(release_sync_point_lock_); 609 base::AutoLock locker(release_sync_point_lock_);
610 release_sync_points_.swap(release_sync_points); 610 release_sync_point_map_.swap(release_sync_points);
611 } 611 }
612 base::ResetAndReturn(&mailbox_holder_release_cb_).Run(release_sync_points); 612 base::ResetAndReturn(&mailbox_holder_release_cb_).Run(release_sync_points);
613 } 613 }
614 if (!no_longer_needed_cb_.is_null()) 614 if (!no_longer_needed_cb_.is_null())
615 base::ResetAndReturn(&no_longer_needed_cb_).Run(); 615 base::ResetAndReturn(&no_longer_needed_cb_).Run();
616 } 616 }
617 617
618 bool VideoFrame::IsValidPlane(size_t plane) const { 618 bool VideoFrame::IsValidPlane(size_t plane) const {
619 return (plane < NumPlanes(format_)); 619 return (plane < NumPlanes(format_));
620 } 620 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 700
701 const gpu::MailboxHolder* VideoFrame::mailbox_holder() const { 701 const gpu::MailboxHolder* VideoFrame::mailbox_holder() const {
702 DCHECK_EQ(format_, NATIVE_TEXTURE); 702 DCHECK_EQ(format_, NATIVE_TEXTURE);
703 return mailbox_holder_.get(); 703 return mailbox_holder_.get();
704 } 704 }
705 705
706 base::SharedMemoryHandle VideoFrame::shared_memory_handle() const { 706 base::SharedMemoryHandle VideoFrame::shared_memory_handle() const {
707 return shared_memory_handle_; 707 return shared_memory_handle_;
708 } 708 }
709 709
710 void VideoFrame::AppendReleaseSyncPoint(uint32 sync_point) { 710 void VideoFrame::AppendReleaseSyncPoint(std::string client, uint32 sync_point) {
711 DCHECK_EQ(format_, NATIVE_TEXTURE); 711 DCHECK_EQ(format_, NATIVE_TEXTURE);
712 if (!sync_point) 712 if (!sync_point)
713 return; 713 return;
714 base::AutoLock locker(release_sync_point_lock_); 714 base::AutoLock locker(release_sync_point_lock_);
715 release_sync_points_.push_back(sync_point); 715 release_sync_point_map_[client] = sync_point;
716 } 716 }
717 717
718 #if defined(OS_POSIX) 718 #if defined(OS_POSIX)
719 int VideoFrame::dmabuf_fd(size_t plane) const { 719 int VideoFrame::dmabuf_fd(size_t plane) const {
720 return dmabuf_fds_[plane].get(); 720 return dmabuf_fds_[plane].get();
721 } 721 }
722 #endif 722 #endif
723 723
724 void VideoFrame::HashFrameForTesting(base::MD5Context* context) { 724 void VideoFrame::HashFrameForTesting(base::MD5Context* context) {
725 for (int plane = 0; plane < kMaxPlanes; ++plane) { 725 for (int plane = 0; plane < kMaxPlanes; ++plane) {
726 if (!IsValidPlane(plane)) 726 if (!IsValidPlane(plane))
727 break; 727 break;
728 for (int row = 0; row < rows(plane); ++row) { 728 for (int row = 0; row < rows(plane); ++row) {
729 base::MD5Update(context, base::StringPiece( 729 base::MD5Update(context, base::StringPiece(
730 reinterpret_cast<char*>(data(plane) + stride(plane) * row), 730 reinterpret_cast<char*>(data(plane) + stride(plane) * row),
731 row_bytes(plane))); 731 row_bytes(plane)));
732 } 732 }
733 } 733 }
734 } 734 }
735 735
736 } // namespace media 736 } // namespace media
OLDNEW
« no previous file with comments | « media/base/video_frame.h ('k') | media/base/video_frame_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698