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_error.hpp>
|
||||
#include <srs_kernel_buffer.hpp>
|
||||
#include <srs_kernel_file.hpp>
|
||||
#include <srs_kernel_io.hpp>
|
||||
#include <srs_kernel_codec.hpp>
|
||||
#include <srs_core_autofree.hpp>
|
||||
|
||||
SrsAacTransmuxer::SrsAacTransmuxer()
|
||||
{
|
||||
_fs = NULL;
|
||||
writer = NULL;
|
||||
got_sequence_header = false;
|
||||
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_assert(fs);
|
||||
|
||||
if (!fs->is_open()) {
|
||||
return srs_error_new(ERROR_KERNEL_AAC_STREAM_CLOSED, "stream is not open");
|
||||
}
|
||||
|
||||
_fs = fs;
|
||||
writer = fs;
|
||||
|
||||
return err;
|
||||
}
|
||||
|
@ -192,12 +188,12 @@ srs_error_t SrsAacTransmuxer::write_audio(int64_t timestamp, char* data, int siz
|
|||
}
|
||||
|
||||
// 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");
|
||||
}
|
||||
|
||||
// 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");
|
||||
}
|
||||
|
||||
|
|
|
@ -33,8 +33,7 @@
|
|||
#include <srs_kernel_codec.hpp>
|
||||
|
||||
class SrsBuffer;
|
||||
class SrsFileWriter;
|
||||
class SrsFileReader;
|
||||
class ISrsStreamWriter;
|
||||
|
||||
/**
|
||||
* Transmux the RTMP packets to AAC stream.
|
||||
|
@ -42,7 +41,7 @@ class SrsFileReader;
|
|||
class SrsAacTransmuxer
|
||||
{
|
||||
private:
|
||||
SrsFileWriter* _fs;
|
||||
ISrsStreamWriter* writer;
|
||||
private:
|
||||
SrsAacObjectType aac_object;
|
||||
int8_t aac_sample_rate;
|
||||
|
@ -57,7 +56,7 @@ public:
|
|||
* @remark user can initialize multiple times to encode multiple aac files.
|
||||
* @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:
|
||||
/**
|
||||
* write audio/video packet.
|
||||
|
|
|
@ -2069,6 +2069,10 @@ SrsMp4ElstEntry::SrsMp4ElstEntry() : segment_duration(0), media_time(0), media_r
|
|||
media_rate_fraction = 0;
|
||||
}
|
||||
|
||||
SrsMp4ElstEntry::~SrsMp4ElstEntry()
|
||||
{
|
||||
}
|
||||
|
||||
stringstream& SrsMp4ElstEntry::dumps(stringstream& ss, SrsMp4DumpContext dc)
|
||||
{
|
||||
return dumps_detail(ss, dc);
|
||||
|
@ -3874,6 +3878,10 @@ SrsMp4SttsEntry::SrsMp4SttsEntry()
|
|||
sample_delta = 0;
|
||||
}
|
||||
|
||||
SrsMp4SttsEntry::~SrsMp4SttsEntry()
|
||||
{
|
||||
}
|
||||
|
||||
stringstream& SrsMp4SttsEntry::dumps_detail(stringstream& ss, SrsMp4DumpContext dc)
|
||||
{
|
||||
ss << "count=" << sample_count << ", delta=" << sample_delta;
|
||||
|
@ -3987,6 +3995,10 @@ SrsMp4CttsEntry::SrsMp4CttsEntry()
|
|||
sample_offset = 0;
|
||||
}
|
||||
|
||||
SrsMp4CttsEntry::~SrsMp4CttsEntry()
|
||||
{
|
||||
}
|
||||
|
||||
stringstream& SrsMp4CttsEntry::dumps_detail(stringstream& ss, SrsMp4DumpContext dc)
|
||||
{
|
||||
ss << "count=" << sample_count << ", offset=" << sample_offset;
|
||||
|
|
|
@ -946,6 +946,7 @@ public:
|
|||
int16_t media_rate_fraction;
|
||||
public:
|
||||
SrsMp4ElstEntry();
|
||||
virtual ~SrsMp4ElstEntry();
|
||||
public:
|
||||
virtual std::stringstream& dumps(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;
|
||||
// Constructor
|
||||
SrsMp4SttsEntry();
|
||||
virtual ~SrsMp4SttsEntry();
|
||||
public:
|
||||
virtual std::stringstream& dumps_detail(std::stringstream& ss, SrsMp4DumpContext dc);
|
||||
};
|
||||
|
@ -1687,6 +1689,7 @@ struct SrsMp4CttsEntry
|
|||
int64_t sample_offset;
|
||||
// Constructor
|
||||
SrsMp4CttsEntry();
|
||||
virtual ~SrsMp4CttsEntry();
|
||||
public:
|
||||
virtual std::stringstream& dumps_detail(std::stringstream& ss, SrsMp4DumpContext dc);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue