Bug 1101534 - Add MP4Sample copy constructor. r=k17e, a=sledru
authorJean-Yves Avenard <jyavenard@mozilla.com>
Fri, 28 Nov 2014 19:31:57 +1100
changeset 242417 5eb75497c4208ea945287e7bbf587b5434a20388
parent 242416 b3ab3869d34621c02a99c8665ff3dcb3cad6364a
child 242418 b688ccc83c0c2f5e0397cb12addc1523243731a4
push id4311
push userraliiev@mozilla.com
push dateMon, 12 Jan 2015 19:37:41 +0000
treeherdermozilla-beta@150c9fed433b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersk17e, sledru
bugs1101534
milestone36.0a2
Bug 1101534 - Add MP4Sample copy constructor. r=k17e, a=sledru
media/libstagefright/binding/DecoderData.cpp
media/libstagefright/binding/include/mp4_demuxer/DecoderData.h
--- a/media/libstagefright/binding/DecoderData.cpp
+++ b/media/libstagefright/binding/DecoderData.cpp
@@ -203,16 +203,31 @@ MP4Sample::MP4Sample()
   , duration(0)
   , byte_offset(0)
   , is_sync_point(0)
   , data(nullptr)
   , size(0)
 {
 }
 
+MP4Sample::MP4Sample(const MP4Sample& copy)
+  : mMediaBuffer(nullptr)
+  , decode_timestamp(copy.decode_timestamp)
+  , composition_timestamp(copy.composition_timestamp)
+  , duration(copy.duration)
+  , byte_offset(copy.byte_offset)
+  , is_sync_point(copy.is_sync_point)
+  , size(copy.size)
+  , crypto(copy.crypto)
+  , prefix_data(copy.prefix_data)
+{
+  extra_buffer = data = new uint8_t[size];
+  memcpy(data, copy.data, size);
+}
+
 MP4Sample::~MP4Sample()
 {
   if (mMediaBuffer) {
     mMediaBuffer->release();
   }
 }
 
 void
--- a/media/libstagefright/binding/include/mp4_demuxer/DecoderData.h
+++ b/media/libstagefright/binding/include/mp4_demuxer/DecoderData.h
@@ -139,16 +139,17 @@ public:
 };
 
 typedef int64_t Microseconds;
 
 class MP4Sample
 {
 public:
   MP4Sample();
+  MP4Sample(const MP4Sample& copy);
   ~MP4Sample();
   void Update(int64_t& aMediaTime);
   void Pad(size_t aPaddingBytes);
 
   stagefright::MediaBuffer* mMediaBuffer;
 
   Microseconds decode_timestamp;
   Microseconds composition_timestamp;