Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion AampDefine.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,10 @@

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

#define PLAYER_NAME "aamp"
#define PLAYER_NAME "aamp"

// Each subsample entry is 6 bytes (2 bytes for clear + 4 bytes for encrypted)
#define MP4_SUBSAMPLE_ENTRY_SIZE 6

/**
* @brief Enumeration for TUNED Event Configuration
Expand Down
254 changes: 254 additions & 0 deletions AampDemuxDataTypes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,254 @@
/*
* If not stated otherwise in this file or this component's license file the
* following copyright and licenses apply:
*
* Copyright 2025 RDK Management
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef __AAMP_DEMUX_DATA_TYPES_H__
#define __AAMP_DEMUX_DATA_TYPES_H__

#include <string>
#include <vector>
#include <cstring> // for std::memset
#include "AampGrowableBuffer.h" // for AampGrowableBuffer
#include "AampTime.h" // for AampTime
#include "StreamOutputFormat.h" // for StreamOutputFormat
#include "AampMediaType.h" // for AampMediaType

/*
* @struct AampPsshData
* @brief PSSH data structure
*/
struct AampPsshData
{
std::string systemID; // 16 bytes UUID
std::vector<uint8_t> pssh; // variable length

// Default constructor
AampPsshData(): systemID(), pssh()
{
}

// Constructor with parameters
AampPsshData(std::string id, std::vector<uint8_t> data): systemID(std::move(id)), pssh(std::move(data))
{
}

// Move constructor and move assignment (allow efficient transfers)
AampPsshData(AampPsshData&&) = default;
AampPsshData& operator=(AampPsshData&&) = default;

// delete copy constructor and copy assignment to prevent accidental copies
AampPsshData(const AampPsshData&) = delete;
AampPsshData& operator=(const AampPsshData&) = delete;
};

/*
* @struct AampCodecInfo
* @brief Codec information structure
*/
struct AampCodecInfo
{
StreamOutputFormat mCodecFormat; // FORMAT_VIDEO_ES_H264, etc
std::vector<uint8_t> mCodecData; // codec private data, e.g. avcC box
bool mIsEncrypted;
union
{
struct
{
uint16_t mChannelCount;
uint16_t mSampleSize;
uint16_t mSampleRate;
uint8_t mObjectTypeId;
uint8_t mStreamType;
uint8_t mUpStream;
uint16_t mBufferSize;
uint32_t mMaxBitrate;
uint32_t mAvgBitrate;
} audio;

struct
{
uint16_t mWidth;
uint16_t mHeight;
uint16_t mFrameCount;
uint16_t mDepth;
uint32_t mHorizontalResolution;
uint32_t mVerticalResolution;
} video;
} mInfo;

/**
* @brief Constructor for AampCodecInfo
*/
AampCodecInfo() : mCodecFormat(FORMAT_INVALID), mIsEncrypted(false), mCodecData()
{
std::memset(&mInfo, 0, sizeof(mInfo));
}

/**
* @brief Constructor for AampCodecInfo with format
* @param format Stream output format
*/
AampCodecInfo(StreamOutputFormat format) : mCodecFormat(format), mIsEncrypted(false), mCodecData()
{
std::memset(&mInfo, 0, sizeof(mInfo));
}

// Delete copy constructor and copy assignment to prevent accidental copies
AampCodecInfo(const AampCodecInfo&) = delete;
AampCodecInfo& operator=(const AampCodecInfo&) = delete;

/**
* @brief Move constructor for AampCodecInfo
* @param other Source AampCodecInfo to move from
*/
AampCodecInfo(AampCodecInfo&& other) noexcept
: mCodecFormat(std::move(other.mCodecFormat))
, mCodecData(std::move(other.mCodecData))
, mIsEncrypted(std::move(other.mIsEncrypted))
, mInfo(std::move(other.mInfo))
{
// Explicitly reset the source object to default state after move
other.mCodecFormat = FORMAT_INVALID;
other.mIsEncrypted = false;
std::memset(&other.mInfo, 0, sizeof(other.mInfo));
// mCodecData is already empty after std::move
}

/** Move assignment operator for AampCodecInfo
* @param other Source AampCodecInfo to move from
*/
AampCodecInfo& operator=(AampCodecInfo&& other) noexcept
{
if (this != &other)
{
mCodecFormat = std::move(other.mCodecFormat);
mCodecData = std::move(other.mCodecData);
mIsEncrypted = std::move(other.mIsEncrypted);
mInfo = std::move(other.mInfo);

// Explicitly reset the source object to default state after move
other.mCodecFormat = FORMAT_INVALID;
other.mIsEncrypted = false;
std::memset(&other.mInfo, 0, sizeof(other.mInfo));
// mCodecData is already empty after std::move
}
return *this;
}
};

/*
* @struct AampDrmMetadata
* @brief DRM metadata for encrypted samples
*/
struct AampDrmMetadata
{
bool mIsEncrypted;
std::string mKeyId; // 16 bytes UUID
std::vector<uint8_t> mIV; // 8 or 16 bytes
std::string mCipher; // e.g. 'cenc', 'cbcs'
std::vector<uint8_t> mSubSamples; // optional subsample encryption data
uint8_t mCryptByteBlock;
uint8_t mSkipByteBlock;

/**
* @brief Constructor for AampDrmMetadata
*/
AampDrmMetadata() : mIsEncrypted(false), mKeyId(), mIV(), mCipher(),
mSubSamples(), mCryptByteBlock(0), mSkipByteBlock(0)
{
}

/**
* @brief Move constructor for AampDrmMetadata
* @param other Source AampDrmMetadata to move from
*/
AampDrmMetadata(AampDrmMetadata&& other) noexcept
: mIsEncrypted(other.mIsEncrypted),
mKeyId(std::move(other.mKeyId)),
mIV(std::move(other.mIV)),
mCipher(std::move(other.mCipher)),
mSubSamples(std::move(other.mSubSamples)),
mCryptByteBlock(other.mCryptByteBlock),
mSkipByteBlock(other.mSkipByteBlock)
{
// Reset source object to default state after move
other.mIsEncrypted = false;
other.mCryptByteBlock = 0;
other.mSkipByteBlock = 0;
}

/**
* @brief Move assignment operator for AampDrmMetadata
* @param other Source AampDrmMetadata to move from
* @return Reference to this object
*/
AampDrmMetadata& operator=(AampDrmMetadata&& other) noexcept
{
if (this != &other)
{
mIsEncrypted = other.mIsEncrypted;
mKeyId = std::move(other.mKeyId);
mIV = std::move(other.mIV);
mCipher = std::move(other.mCipher);
mSubSamples = std::move(other.mSubSamples);
mCryptByteBlock = other.mCryptByteBlock;
mSkipByteBlock = other.mSkipByteBlock;

// Reset source object to default state after move
other.mIsEncrypted = false;
other.mCryptByteBlock = 0;
other.mSkipByteBlock = 0;
}
return *this;
}

// Delete copy constructor and copy assignment to prevent accidental copies
AampDrmMetadata(const AampDrmMetadata&) = delete;
AampDrmMetadata& operator=(const AampDrmMetadata&) = delete;
};

/*
* @struct AampMediaSample
* @brief Media sample structure
*/
struct AampMediaSample
{
AampGrowableBuffer mData;
AampTime mPts;
AampTime mDts;
AampTime mDuration;

AampDrmMetadata mDrmMetadata; // empty if not encrypted

/**
* @brief Constructor for AampMediaSample
*/
AampMediaSample() : mData("AampMediaSample"), mPts(0), mDts(0), mDuration(0), mDrmMetadata()
{
}

// Move constructor and move assignment (allow efficient transfers)
AampMediaSample(AampMediaSample&&) = default;
AampMediaSample& operator=(AampMediaSample&&) = default;

// Delete copy constructor and copy assignment to prevent accidental copies
AampMediaSample(const AampMediaSample&) = delete;
AampMediaSample& operator=(const AampMediaSample&) = delete;
};

#endif /* __AAMP_DEMUX_DATA_TYPES_H__ */
9 changes: 9 additions & 0 deletions AampStreamSinkInactive.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@ class AampStreamSinkInactive : public StreamSink
return false;
}
/**
* @fn SendSample
* @brief stub implementation for Inactive aamp instance
*/
virtual bool SendSample( AampMediaType mediaType, AampMediaSample& sample)
{
AAMPLOG_WARN("Called AAMPGstPlayer()::%s stub", __FUNCTION__);
return false;
}
/**
* @fn EndOfStreamReached
* @brief stub implementation for Inactive aamp instance
*/
Expand Down
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/jsbindings)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/jsbindings/PersistentWatermark)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/subtec/subtecparser)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/subtitle)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/test/gstTestHarness)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/mp4demux)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/tsb/api)

# Locally built/installed dependencies are here
Expand Down Expand Up @@ -351,10 +351,12 @@ set(LIBAAMP_SOURCES
subtec/subtecparser/WebvttSubtecDevParser.cpp
AampTrackWorker.cpp AampTrackWorker.h
LangCodePreference.h
test/gstTestHarness/mp4demux.hpp
AampTrackWorkerManager.cpp
AampFragmentDescriptor.cpp
AampTimeBasedBufferManager.cpp
mp4demux/AampMp4Demuxer.cpp mp4demux/AampMp4Demuxer.h
mp4demux/MP4Demux.cpp mp4demux/MP4Demux.h
AampDemuxDataTypes.h
)

if(CMAKE_SOC_PLATFORM_RPI)
Expand Down Expand Up @@ -518,6 +520,7 @@ install(FILES
MediaSegmentDownloadJob.hpp
tsb/api/TsbApi.h
LangCodePreference.h StreamOutputFormat.h VideoZoomMode.h StreamSink.h TimedMetadata.h
AampDemuxDataTypes.h AampTime.h
DESTINATION include
)

Expand Down
1 change: 0 additions & 1 deletion ElementaryProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ bool ElementaryProcessor::setTuneTimePTS(char *segment, const size_t& size, doub

AAMPLOG_INFO("ElementaryProcessor:: sending segment at pos:%f dur:%f", position, duration);

// Logic for Audio Track
// Wait for video to parse PTS
std::unique_lock<std::mutex> guard(accessMutex);

Expand Down
1 change: 1 addition & 0 deletions StreamAbstractionAAMP.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#include "AampTime.h"
#include "AampTimeBasedBufferManager.hpp"
#include "CachedFragment.h"
#include "AampDemuxDataTypes.h"

/**
* @brief Media Track Types
Expand Down
1 change: 1 addition & 0 deletions StreamOutputFormat.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ enum StreamOutputFormat
FORMAT_ISO_BMFF, /**< ISO Base Media File format */
FORMAT_AUDIO_ES_MP3, /**< MP3 Audio Elementary Stream */
FORMAT_AUDIO_ES_AAC, /**< AAC Audio Elementary Stream */
FORMAT_AUDIO_ES_AAC_RAW,/**< AAC Raw Audio Elementary Stream */
FORMAT_AUDIO_ES_AC3, /**< AC3 Audio Elementary Stream */
FORMAT_AUDIO_ES_EC3, /**< Dolby Digital Plus Elementary Stream */
FORMAT_AUDIO_ES_ATMOS, /**< ATMOS Audio stream */
Expand Down
11 changes: 11 additions & 0 deletions StreamSink.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include "StreamOutputFormat.h"
#include "AampMediaType.h"
#include "AampDemuxDataTypes.h"

/**
* @struct PlaybackQualityData
Expand Down Expand Up @@ -81,6 +82,8 @@ class StreamSink
*/
virtual bool SendTransfer( AampMediaType mediaType, void *ptr, size_t len, double fpts, double fdts, double fDuration, double fragmentPTSoffset, bool initFragment = false, bool discontinuity = false)= 0;

virtual bool SendSample( AampMediaType mediaType, AampMediaSample& sample ) = 0;

/**
* @brief Checks pipeline is configured for media type
*
Expand Down Expand Up @@ -390,6 +393,14 @@ class StreamSink
*/
virtual void NotifyInjectorToPause() {};

/**
* @brief Set stream capabilities based on codec info
*
* @param[in] type - Media type
* @param[in] codecInfo - Codec information
*/
virtual void SetStreamCaps(AampMediaType type, AampCodecInfo &&codecInfo) {};

};

#endif // STREAM_SINK_H
Loading
Loading