Skip to content

Commit 0067eef

Browse files
committed
VPLAY-11143: AAMP mp4Demux Integration
Reason for change: Fix review comments. Introduced error detection and propogation in Mp4Demuxer. Code cleanup Test Procedure: As mentioned in the ticket Risks: Low Signed-off-by: Vinish100 <[email protected]>
1 parent 3e1895b commit 0067eef

File tree

29 files changed

+531
-125
lines changed

29 files changed

+531
-125
lines changed

AampDefine.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,10 @@
235235

236236
#define MAX_SESSION_ID_LENGTH 128 /**<session id string length */
237237

238-
#define PLAYER_NAME "aamp"
238+
#define PLAYER_NAME "aamp"
239+
240+
// Each subsample entry is 6 bytes (2 bytes for clear + 4 bytes for encrypted)
241+
#define MP4_SUBSAMPLE_ENTRY_SIZE 6
239242

240243
/**
241244
* @brief Enumeration for TUNED Event Configuration

AampDemuxDataTypes.h

Lines changed: 120 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,24 @@ struct AampPsshData
3636
{
3737
std::string systemID; // 16 bytes UUID
3838
std::vector<uint8_t> pssh; // variable length
39+
40+
// Default constructor
41+
AampPsshData(): systemID(), pssh()
42+
{
43+
}
44+
45+
// Constructor with parameters
46+
AampPsshData(std::string id, std::vector<uint8_t> data): systemID(std::move(id)), pssh(std::move(data))
47+
{
48+
}
49+
50+
// Move constructor and move assignment (allow efficient transfers)
51+
AampPsshData(AampPsshData&&) = default;
52+
AampPsshData& operator=(AampPsshData&&) = default;
53+
54+
// delete copy constructor and copy assignment to prevent accidental copies
55+
AampPsshData(const AampPsshData&) = delete;
56+
AampPsshData& operator=(const AampPsshData&) = delete;
3957
};
4058

4159
/*
@@ -73,28 +91,64 @@ struct AampCodecInfo
7391
} video;
7492
} mInfo;
7593

94+
/**
95+
* @brief Constructor for AampCodecInfo
96+
*/
7697
AampCodecInfo() : mCodecFormat(FORMAT_INVALID), mIsEncrypted(false), mCodecData()
7798
{
7899
std::memset(&mInfo, 0, sizeof(mInfo));
79100
}
80101

102+
/**
103+
* @brief Constructor for AampCodecInfo with format
104+
* @param format Stream output format
105+
*/
81106
AampCodecInfo(StreamOutputFormat format) : mCodecFormat(format), mIsEncrypted(false), mCodecData()
82107
{
83108
std::memset(&mInfo, 0, sizeof(mInfo));
84109
}
85110

111+
// Delete copy constructor and copy assignment to prevent accidental copies
112+
AampCodecInfo(const AampCodecInfo&) = delete;
113+
AampCodecInfo& operator=(const AampCodecInfo&) = delete;
114+
115+
/**
116+
* @brief Move constructor for AampCodecInfo
117+
* @param other Source AampCodecInfo to move from
118+
*/
86119
AampCodecInfo(AampCodecInfo&& other) noexcept
87-
: mCodecFormat(other.mCodecFormat)
120+
: mCodecFormat(std::move(other.mCodecFormat))
88121
, mCodecData(std::move(other.mCodecData))
89-
, mIsEncrypted(other.mIsEncrypted)
90-
, mInfo(other.mInfo)
122+
, mIsEncrypted(std::move(other.mIsEncrypted))
123+
, mInfo(std::move(other.mInfo))
91124
{
92-
// Reset the source object to default state
125+
// Explicitly reset the source object to default state after move
93126
other.mCodecFormat = FORMAT_INVALID;
94127
other.mIsEncrypted = false;
95128
std::memset(&other.mInfo, 0, sizeof(other.mInfo));
96129
// mCodecData is already empty after std::move
97130
}
131+
132+
/** Move assignment operator for AampCodecInfo
133+
* @param other Source AampCodecInfo to move from
134+
*/
135+
AampCodecInfo& operator=(AampCodecInfo&& other) noexcept
136+
{
137+
if (this != &other)
138+
{
139+
mCodecFormat = std::move(other.mCodecFormat);
140+
mCodecData = std::move(other.mCodecData);
141+
mIsEncrypted = std::move(other.mIsEncrypted);
142+
mInfo = std::move(other.mInfo);
143+
144+
// Explicitly reset the source object to default state after move
145+
other.mCodecFormat = FORMAT_INVALID;
146+
other.mIsEncrypted = false;
147+
std::memset(&other.mInfo, 0, sizeof(other.mInfo));
148+
// mCodecData is already empty after std::move
149+
}
150+
return *this;
151+
}
98152
};
99153

100154
/*
@@ -111,10 +165,61 @@ struct AampDrmMetadata
111165
uint8_t mCryptByteBlock;
112166
uint8_t mSkipByteBlock;
113167

168+
/**
169+
* @brief Constructor for AampDrmMetadata
170+
*/
114171
AampDrmMetadata() : mIsEncrypted(false), mKeyId(), mIV(), mCipher(),
115172
mSubSamples(), mCryptByteBlock(0), mSkipByteBlock(0)
116173
{
117174
}
175+
176+
/**
177+
* @brief Move constructor for AampDrmMetadata
178+
* @param other Source AampDrmMetadata to move from
179+
*/
180+
AampDrmMetadata(AampDrmMetadata&& other) noexcept
181+
: mIsEncrypted(other.mIsEncrypted),
182+
mKeyId(std::move(other.mKeyId)),
183+
mIV(std::move(other.mIV)),
184+
mCipher(std::move(other.mCipher)),
185+
mSubSamples(std::move(other.mSubSamples)),
186+
mCryptByteBlock(other.mCryptByteBlock),
187+
mSkipByteBlock(other.mSkipByteBlock)
188+
{
189+
// Reset source object to default state after move
190+
other.mIsEncrypted = false;
191+
other.mCryptByteBlock = 0;
192+
other.mSkipByteBlock = 0;
193+
}
194+
195+
/**
196+
* @brief Move assignment operator for AampDrmMetadata
197+
* @param other Source AampDrmMetadata to move from
198+
* @return Reference to this object
199+
*/
200+
AampDrmMetadata& operator=(AampDrmMetadata&& other) noexcept
201+
{
202+
if (this != &other)
203+
{
204+
mIsEncrypted = other.mIsEncrypted;
205+
mKeyId = std::move(other.mKeyId);
206+
mIV = std::move(other.mIV);
207+
mCipher = std::move(other.mCipher);
208+
mSubSamples = std::move(other.mSubSamples);
209+
mCryptByteBlock = other.mCryptByteBlock;
210+
mSkipByteBlock = other.mSkipByteBlock;
211+
212+
// Reset source object to default state after move
213+
other.mIsEncrypted = false;
214+
other.mCryptByteBlock = 0;
215+
other.mSkipByteBlock = 0;
216+
}
217+
return *this;
218+
}
219+
220+
// Delete copy constructor and copy assignment to prevent accidental copies
221+
AampDrmMetadata(const AampDrmMetadata&) = delete;
222+
AampDrmMetadata& operator=(const AampDrmMetadata&) = delete;
118223
};
119224

120225
/*
@@ -130,9 +235,20 @@ struct AampMediaSample
130235

131236
AampDrmMetadata mDrmMetadata; // empty if not encrypted
132237

238+
/**
239+
* @brief Constructor for AampMediaSample
240+
*/
133241
AampMediaSample() : mData("AampMediaSample"), mPts(0), mDts(0), mDuration(0), mDrmMetadata()
134242
{
135243
}
244+
245+
// Move constructor and move assignment (allow efficient transfers)
246+
AampMediaSample(AampMediaSample&&) = default;
247+
AampMediaSample& operator=(AampMediaSample&&) = default;
248+
249+
// Delete copy constructor and copy assignment to prevent accidental copies
250+
AampMediaSample(const AampMediaSample&) = delete;
251+
AampMediaSample& operator=(const AampMediaSample&) = delete;
136252
};
137253

138254
#endif /* __AAMP_DEMUX_DATA_TYPES_H__ */

StreamSink.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ class StreamSink
399399
* @param[in] type - Media type
400400
* @param[in] codecInfo - Codec information
401401
*/
402-
virtual void SetStreamCaps(AampMediaType type, const AampCodecInfo &codecInfo) {};
402+
virtual void SetStreamCaps(AampMediaType type, AampCodecInfo &&codecInfo) {};
403403

404404
};
405405

aampgstplayer.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ void AAMPGstPlayer::NotifyInjectorToResume()
678678
/**
679679
* @brief Inject stream buffer to gstreamer pipeline
680680
*/
681-
bool AAMPGstPlayer::SendHelper(AampMediaType mediaType, MediaSample sample, bool copy, bool initFragment, bool discontinuity)
681+
bool AAMPGstPlayer::SendHelper(AampMediaType mediaType, MediaSample&& sample, bool copy, bool initFragment, bool discontinuity)
682682
{
683683
if(ISCONFIGSET(eAAMPConfig_SuppressDecode))
684684
{
@@ -1336,7 +1336,7 @@ void AAMPGstPlayer::StopMonitorAvTimer()
13361336
* @param[in] type - Media type
13371337
* @param[in] codecInfo - Codec information
13381338
*/
1339-
void AAMPGstPlayer::SetStreamCaps(AampMediaType type, const AampCodecInfo &codecInfo)
1339+
void AAMPGstPlayer::SetStreamCaps(AampMediaType type, AampCodecInfo &&codecInfo)
13401340
{
13411341
CodecInfo gstCodecInfo;
13421342
gstCodecInfo.codecFormat = (GstStreamOutputFormat)codecInfo.mCodecFormat;
@@ -1355,9 +1355,15 @@ void AAMPGstPlayer::SetStreamCaps(AampMediaType type, const AampCodecInfo &codec
13551355
playerInstance->SetStreamCaps((GstMediaType)type, gstCodecInfo);
13561356
}
13571357

1358+
/**
1359+
* @brief Inject AampMediaSample to gstreamer pipeline
1360+
*
1361+
* @param[in] mediaType - Media type
1362+
* @param[in,out] sample - Media sample to inject
1363+
* @return true if sample is successfully injected, false otherwise
1364+
*/
13581365
bool AAMPGstPlayer::SendSample(AampMediaType mediaType, AampMediaSample& sample)
13591366
{
1360-
bool ret = false;
13611367
MediaSample gstSample;
13621368

13631369
// Convert AampMediaSample to MediaSample
@@ -1382,7 +1388,7 @@ bool AAMPGstPlayer::SendSample(AampMediaType mediaType, AampMediaSample& sample)
13821388
gstSample.drmMetadata.isEncrypted = false;
13831389
}
13841390

1385-
ret = SendHelper( mediaType, std::move(gstSample), false /*transfer*/);
1391+
bool ret = SendHelper( mediaType, std::move(gstSample), false /*transfer*/);
13861392

13871393
if (ret)
13881394
{

aampgstplayer.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class AAMPGstPlayer : public StreamSink
105105
* @param[in] copy to map or transfer the buffer
106106
* @param[in] initFragment flag for buffer type (init, data)
107107
*/
108-
bool SendHelper(AampMediaType mediaType, MediaSample sample, bool copy, bool initFragment = false, bool discontinuity = false);
108+
bool SendHelper(AampMediaType mediaType, MediaSample&& sample, bool copy, bool initFragment = false, bool discontinuity = false);
109109

110110
public:
111111
class PrivateInstanceAAMP *aamp;
@@ -145,7 +145,13 @@ class AAMPGstPlayer : public StreamSink
145145
*/
146146
bool SendTransfer(AampMediaType mediaType, void *ptr, size_t len, double fpts, double fdts, double fDuration, double fragmentPTSoffset, bool initFragment = false, bool discontinuity = false) override;
147147

148-
bool SendSample( AampMediaType mediaType, AampMediaSample& sample ) override;
148+
/**
149+
* @fn SendSample
150+
* @param[in] mediaType stream type
151+
* @param[in] sample media sample
152+
*/
153+
bool SendSample(AampMediaType mediaType, AampMediaSample& sample) override;
154+
149155
/**
150156
* @fn PipelineConfiguredForMedia
151157
* @param[in] type stream type
@@ -436,7 +442,7 @@ class AAMPGstPlayer : public StreamSink
436442
* @param[in] type - Media type
437443
* @param[in] codecInfo - Codec information
438444
*/
439-
void SetStreamCaps(AampMediaType type, const AampCodecInfo &codecInfo) override;
445+
void SetStreamCaps(AampMediaType type, AampCodecInfo &&codecInfo) override;
440446

441447
private:
442448
std::mutex mBufferingLock;

0 commit comments

Comments
 (0)