mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Refine kernel aac
This commit is contained in:
parent
572a2806c1
commit
dcc2a73e7a
4 changed files with 24 additions and 14 deletions
|
@ -37,13 +37,13 @@ using namespace std;
|
||||||
#include <srs_kernel_log.hpp>
|
#include <srs_kernel_log.hpp>
|
||||||
#include <srs_kernel_error.hpp>
|
#include <srs_kernel_error.hpp>
|
||||||
#include <srs_kernel_buffer.hpp>
|
#include <srs_kernel_buffer.hpp>
|
||||||
#include <srs_kernel_file.hpp>
|
#include <srs_kernel_io.hpp>
|
||||||
#include <srs_kernel_codec.hpp>
|
#include <srs_kernel_codec.hpp>
|
||||||
#include <srs_core_autofree.hpp>
|
#include <srs_core_autofree.hpp>
|
||||||
|
|
||||||
SrsAacTransmuxer::SrsAacTransmuxer()
|
SrsAacTransmuxer::SrsAacTransmuxer()
|
||||||
{
|
{
|
||||||
_fs = NULL;
|
writer = NULL;
|
||||||
got_sequence_header = false;
|
got_sequence_header = false;
|
||||||
aac_object = SrsAacObjectTypeReserved;
|
aac_object = SrsAacObjectTypeReserved;
|
||||||
}
|
}
|
||||||
|
@ -52,17 +52,13 @@ SrsAacTransmuxer::~SrsAacTransmuxer()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
srs_error_t SrsAacTransmuxer::initialize(SrsFileWriter* fs)
|
srs_error_t SrsAacTransmuxer::initialize(ISrsStreamWriter* fs)
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
|
||||||
srs_assert(fs);
|
srs_assert(fs);
|
||||||
|
|
||||||
if (!fs->is_open()) {
|
writer = fs;
|
||||||
return srs_error_new(ERROR_KERNEL_AAC_STREAM_CLOSED, "stream is not open");
|
|
||||||
}
|
|
||||||
|
|
||||||
_fs = fs;
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -192,12 +188,12 @@ srs_error_t SrsAacTransmuxer::write_audio(int64_t timestamp, char* data, int siz
|
||||||
}
|
}
|
||||||
|
|
||||||
// write 7bytes fixed header.
|
// write 7bytes fixed header.
|
||||||
if ((err = _fs->write(aac_fixed_header, 7, NULL)) != srs_success) {
|
if ((err = writer->write(aac_fixed_header, 7, NULL)) != srs_success) {
|
||||||
return srs_error_wrap(err, "write aac header");
|
return srs_error_wrap(err, "write aac header");
|
||||||
}
|
}
|
||||||
|
|
||||||
// write aac frame body.
|
// write aac frame body.
|
||||||
if ((err = _fs->write(data + stream->pos(), aac_raw_length, NULL)) != srs_success) {
|
if ((err = writer->write(data + stream->pos(), aac_raw_length, NULL)) != srs_success) {
|
||||||
return srs_error_wrap(err, "write aac frame");
|
return srs_error_wrap(err, "write aac frame");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,8 +33,7 @@
|
||||||
#include <srs_kernel_codec.hpp>
|
#include <srs_kernel_codec.hpp>
|
||||||
|
|
||||||
class SrsBuffer;
|
class SrsBuffer;
|
||||||
class SrsFileWriter;
|
class ISrsStreamWriter;
|
||||||
class SrsFileReader;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transmux the RTMP packets to AAC stream.
|
* Transmux the RTMP packets to AAC stream.
|
||||||
|
@ -42,7 +41,7 @@ class SrsFileReader;
|
||||||
class SrsAacTransmuxer
|
class SrsAacTransmuxer
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
SrsFileWriter* _fs;
|
ISrsStreamWriter* writer;
|
||||||
private:
|
private:
|
||||||
SrsAacObjectType aac_object;
|
SrsAacObjectType aac_object;
|
||||||
int8_t aac_sample_rate;
|
int8_t aac_sample_rate;
|
||||||
|
@ -57,7 +56,7 @@ public:
|
||||||
* @remark user can initialize multiple times to encode multiple aac files.
|
* @remark user can initialize multiple times to encode multiple aac files.
|
||||||
* @remark, user must free the fs, aac encoder never close/free it.
|
* @remark, user must free the fs, aac encoder never close/free it.
|
||||||
*/
|
*/
|
||||||
virtual srs_error_t initialize(SrsFileWriter* fs);
|
virtual srs_error_t initialize(ISrsStreamWriter* fs);
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* write audio/video packet.
|
* write audio/video packet.
|
||||||
|
|
|
@ -2069,6 +2069,10 @@ SrsMp4ElstEntry::SrsMp4ElstEntry() : segment_duration(0), media_time(0), media_r
|
||||||
media_rate_fraction = 0;
|
media_rate_fraction = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SrsMp4ElstEntry::~SrsMp4ElstEntry()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
stringstream& SrsMp4ElstEntry::dumps(stringstream& ss, SrsMp4DumpContext dc)
|
stringstream& SrsMp4ElstEntry::dumps(stringstream& ss, SrsMp4DumpContext dc)
|
||||||
{
|
{
|
||||||
return dumps_detail(ss, dc);
|
return dumps_detail(ss, dc);
|
||||||
|
@ -3874,6 +3878,10 @@ SrsMp4SttsEntry::SrsMp4SttsEntry()
|
||||||
sample_delta = 0;
|
sample_delta = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SrsMp4SttsEntry::~SrsMp4SttsEntry()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
stringstream& SrsMp4SttsEntry::dumps_detail(stringstream& ss, SrsMp4DumpContext dc)
|
stringstream& SrsMp4SttsEntry::dumps_detail(stringstream& ss, SrsMp4DumpContext dc)
|
||||||
{
|
{
|
||||||
ss << "count=" << sample_count << ", delta=" << sample_delta;
|
ss << "count=" << sample_count << ", delta=" << sample_delta;
|
||||||
|
@ -3987,6 +3995,10 @@ SrsMp4CttsEntry::SrsMp4CttsEntry()
|
||||||
sample_offset = 0;
|
sample_offset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SrsMp4CttsEntry::~SrsMp4CttsEntry()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
stringstream& SrsMp4CttsEntry::dumps_detail(stringstream& ss, SrsMp4DumpContext dc)
|
stringstream& SrsMp4CttsEntry::dumps_detail(stringstream& ss, SrsMp4DumpContext dc)
|
||||||
{
|
{
|
||||||
ss << "count=" << sample_count << ", offset=" << sample_offset;
|
ss << "count=" << sample_count << ", offset=" << sample_offset;
|
||||||
|
|
|
@ -946,6 +946,7 @@ public:
|
||||||
int16_t media_rate_fraction;
|
int16_t media_rate_fraction;
|
||||||
public:
|
public:
|
||||||
SrsMp4ElstEntry();
|
SrsMp4ElstEntry();
|
||||||
|
virtual ~SrsMp4ElstEntry();
|
||||||
public:
|
public:
|
||||||
virtual std::stringstream& dumps(std::stringstream& ss, SrsMp4DumpContext dc);
|
virtual std::stringstream& dumps(std::stringstream& ss, SrsMp4DumpContext dc);
|
||||||
virtual std::stringstream& dumps_detail(std::stringstream& ss, SrsMp4DumpContext dc);
|
virtual std::stringstream& dumps_detail(std::stringstream& ss, SrsMp4DumpContext dc);
|
||||||
|
@ -1635,6 +1636,7 @@ struct SrsMp4SttsEntry
|
||||||
uint32_t sample_delta;
|
uint32_t sample_delta;
|
||||||
// Constructor
|
// Constructor
|
||||||
SrsMp4SttsEntry();
|
SrsMp4SttsEntry();
|
||||||
|
virtual ~SrsMp4SttsEntry();
|
||||||
public:
|
public:
|
||||||
virtual std::stringstream& dumps_detail(std::stringstream& ss, SrsMp4DumpContext dc);
|
virtual std::stringstream& dumps_detail(std::stringstream& ss, SrsMp4DumpContext dc);
|
||||||
};
|
};
|
||||||
|
@ -1687,6 +1689,7 @@ struct SrsMp4CttsEntry
|
||||||
int64_t sample_offset;
|
int64_t sample_offset;
|
||||||
// Constructor
|
// Constructor
|
||||||
SrsMp4CttsEntry();
|
SrsMp4CttsEntry();
|
||||||
|
virtual ~SrsMp4CttsEntry();
|
||||||
public:
|
public:
|
||||||
virtual std::stringstream& dumps_detail(std::stringstream& ss, SrsMp4DumpContext dc);
|
virtual std::stringstream& dumps_detail(std::stringstream& ss, SrsMp4DumpContext dc);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue