OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/cast/sender/h264_vt_encoder.h" | 5 #include "media/cast/sender/h264_vt_encoder.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/big_endian.h" | 10 #include "base/big_endian.h" |
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
722 keyframe = !CFDictionaryContainsKey( | 722 keyframe = !CFDictionaryContainsKey( |
723 sample_attachments, | 723 sample_attachments, |
724 CoreMediaGlue::kCMSampleAttachmentKey_NotSync()); | 724 CoreMediaGlue::kCMSampleAttachmentKey_NotSync()); |
725 has_frame_data = true; | 725 has_frame_data = true; |
726 } | 726 } |
727 | 727 |
728 // Increment the encoder-scoped frame id and assign the new value to this | 728 // Increment the encoder-scoped frame id and assign the new value to this |
729 // frame. VideoToolbox calls the output callback serially, so this is safe. | 729 // frame. VideoToolbox calls the output callback serially, so this is safe. |
730 const uint32 frame_id = ++encoder->last_frame_id_; | 730 const uint32 frame_id = ++encoder->last_frame_id_; |
731 | 731 |
732 scoped_ptr<SenderEncodedFrame> encoded_frame(new SenderEncodedFrame()); | 732 scoped_ptr<EncodedFrame> encoded_frame(new EncodedFrame()); |
733 encoded_frame->frame_id = frame_id; | 733 encoded_frame->frame_id = frame_id; |
734 encoded_frame->reference_time = request->reference_time; | 734 encoded_frame->reference_time = request->reference_time; |
735 encoded_frame->rtp_timestamp = request->rtp_timestamp; | 735 encoded_frame->rtp_timestamp = request->rtp_timestamp; |
736 if (keyframe) { | 736 if (keyframe) { |
737 encoded_frame->dependency = EncodedFrame::KEY; | 737 encoded_frame->dependency = EncodedFrame::KEY; |
738 encoded_frame->referenced_frame_id = frame_id; | 738 encoded_frame->referenced_frame_id = frame_id; |
739 } else { | 739 } else { |
740 encoded_frame->dependency = EncodedFrame::DEPENDENT; | 740 encoded_frame->dependency = EncodedFrame::DEPENDENT; |
741 // H.264 supports complex frame reference schemes (multiple reference | 741 // H.264 supports complex frame reference schemes (multiple reference |
742 // frames, slice references, backward and forward references, etc). Cast | 742 // frames, slice references, backward and forward references, etc). Cast |
743 // doesn't support the concept of forward-referencing frame dependencies or | 743 // doesn't support the concept of forward-referencing frame dependencies or |
744 // multiple frame dependencies; so pretend that all frames are only | 744 // multiple frame dependencies; so pretend that all frames are only |
745 // decodable after their immediately preceding frame is decoded. This will | 745 // decodable after their immediately preceding frame is decoded. This will |
746 // ensure a Cast receiver only attempts to decode the frames sequentially | 746 // ensure a Cast receiver only attempts to decode the frames sequentially |
747 // and in order. Furthermore, the encoder is configured to never use forward | 747 // and in order. Furthermore, the encoder is configured to never use forward |
748 // references (see |kVTCompressionPropertyKey_AllowFrameReordering|). There | 748 // references (see |kVTCompressionPropertyKey_AllowFrameReordering|). There |
749 // is no way to prevent multiple reference frames. | 749 // is no way to prevent multiple reference frames. |
750 encoded_frame->referenced_frame_id = frame_id - 1; | 750 encoded_frame->referenced_frame_id = frame_id - 1; |
751 } | 751 } |
752 | 752 |
753 if (has_frame_data) | 753 if (has_frame_data) |
754 CopySampleBufferToAnnexBBuffer(sbuf, &encoded_frame->data, keyframe); | 754 CopySampleBufferToAnnexBBuffer(sbuf, &encoded_frame->data, keyframe); |
755 | 755 |
756 // TODO(miu): Compute and populate the |deadline_utilization| and | |
757 // |lossy_utilization| performance metrics in |encoded_frame|. | |
758 | |
759 encoder->cast_environment_->PostTask( | 756 encoder->cast_environment_->PostTask( |
760 CastEnvironment::MAIN, FROM_HERE, | 757 CastEnvironment::MAIN, FROM_HERE, |
761 base::Bind(request->frame_encoded_callback, | 758 base::Bind(request->frame_encoded_callback, |
762 base::Passed(&encoded_frame))); | 759 base::Passed(&encoded_frame))); |
763 } | 760 } |
764 | 761 |
765 } // namespace cast | 762 } // namespace cast |
766 } // namespace media | 763 } // namespace media |
OLD | NEW |