Commit f631fa25 authored by François Grisez's avatar François Grisez
Browse files

Place byte stream manipulation functions into a static class.

parent 8a9bc152
......@@ -79,7 +79,7 @@ void MediaCodecDecoderFilterImpl::process() {
}
}
nalusToByteStream(&nalus, _bitstream);
H26xUtils::nalusToByteStream(&nalus, _bitstream);
size_t size = _bitstream.size();
//Initialize the video size
if (_codec == nullptr) {
......
......@@ -197,7 +197,7 @@ bool MediaCodecEncoder::fetch(MSQueue *encodedData) {
return false;
}
byteStreamToNalus(buf + info.offset, info.size, &outq);
H26xUtils::byteStreamToNalus(buf + info.offset, info.size, &outq);
_psInserter->process(&outq, encodedData);
AMediaCodec_releaseOutputBuffer(_impl, obufidx, FALSE);
......
......@@ -34,7 +34,7 @@ using namespace std;
extern "C" {
void ms_h264_bitstream_to_nalus(const uint8_t *bitstream, size_t size, MSQueue *nalus) {
byteStreamToNalus(bitstream, size, nalus);
H26xUtils::byteStreamToNalus(bitstream, size, nalus);
}
uint8_t ms_h264_nalu_get_nri(const mblk_t *nalu) {
......
......@@ -28,11 +28,11 @@ using namespace std;
namespace mediastreamer {
void naluStreamToNalus(const std::vector<uint8_t> &byteStream, MSQueue *out) {
naluStreamToNalus(byteStream.data(), byteStream.size(), out);
void H26xUtils::naluStreamToNalus(const std::vector<uint8_t> &byteStream, MSQueue *out) {
H26xUtils::naluStreamToNalus(byteStream.data(), byteStream.size(), out);
}
void naluStreamToNalus(const uint8_t *bytestream, size_t size, MSQueue *out) {
void H26xUtils::naluStreamToNalus(const uint8_t *bytestream, size_t size, MSQueue *out) {
const uint8_t *ptr = bytestream;
while (ptr < bytestream + size) {
uint32_t nalu_size;
......@@ -48,11 +48,11 @@ void naluStreamToNalus(const uint8_t *bytestream, size_t size, MSQueue *out) {
}
}
void byteStreamToNalus(const std::vector<uint8_t> &byteStream, MSQueue *out) {
byteStreamToNalus(byteStream.data(), byteStream.size(), out);
void H26xUtils::byteStreamToNalus(const std::vector<uint8_t> &byteStream, MSQueue *out) {
H26xUtils::byteStreamToNalus(byteStream.data(), byteStream.size(), out);
}
void byteStreamToNalus(const uint8_t *byteStream, size_t size, MSQueue *out) {
void H26xUtils::byteStreamToNalus(const uint8_t *byteStream, size_t size, MSQueue *out) {
vector<uint8_t> buffer;
const uint8_t *end = byteStream + size;
for (const uint8_t *it = byteStream; it != end;) {
......@@ -86,7 +86,7 @@ void byteStreamToNalus(const uint8_t *byteStream, size_t size, MSQueue *out) {
}
}
void nalusToByteStream(MSQueue *nalus, std::vector<uint8_t> &byteStream) {
void H26xUtils::nalusToByteStream(MSQueue *nalus, std::vector<uint8_t> &byteStream) {
bool startPicture = true;
byteStream.resize(0);
while (mblk_t *im = ms_queue_get(nalus)) {
......
......@@ -26,13 +26,19 @@
namespace mediastreamer {
void naluStreamToNalus(const std::vector<uint8_t> &byteStream, MSQueue *out);
void naluStreamToNalus(const uint8_t *byteStream, size_t size, MSQueue *out);
void byteStreamToNalus(const std::vector<uint8_t> &byteStream, MSQueue *out);
void byteStreamToNalus(const uint8_t *byteStream, size_t size, MSQueue *out);
class H26xUtils {
public:
H26xUtils() = delete;
static void naluStreamToNalus(const std::vector<uint8_t> &byteStream, MSQueue *out);
static void naluStreamToNalus(const uint8_t *byteStream, size_t size, MSQueue *out);
void nalusToByteStream(MSQueue *nalus, std::vector<uint8_t> &bytestream);
static void byteStreamToNalus(const std::vector<uint8_t> &byteStream, MSQueue *out);
static void byteStreamToNalus(const uint8_t *byteStream, size_t size, MSQueue *out);
static void nalusToByteStream(MSQueue *nalus, std::vector<uint8_t> &bytestream);
};
class H26xParameterSetsInserter {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment