Add support for Opus streaming
This commit is contained in:
parent
a1dd141588
commit
02be5a979a
|
@ -0,0 +1,20 @@
|
|||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
||||
#include "conn.hh"
|
||||
#include "rtp_opus.hh"
|
||||
#include "rtp_generic.hh"
|
||||
|
||||
int RTPOpus::pushOpusFrame(RTPConnection *conn, uint8_t *data, uint32_t dataLen, uint32_t timestamp)
|
||||
{
|
||||
uint8_t buffer[MAX_PACKET] = { 0 };
|
||||
RTPOpus::OpusConfig *config = (RTPOpus::OpusConfig *)conn->getConfig();
|
||||
|
||||
buffer[0] = (config->configurationNumber << 3) |
|
||||
(config->channels > 1 ? (1 << 2) : 0) | 0;
|
||||
|
||||
memcpy(&buffer[1], data, dataLen);
|
||||
conn->setPayload(RTP_FORMAT_OPUS);
|
||||
|
||||
return RTPGeneric::pushGenericFrame(conn, buffer, dataLen + 1, 0);
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
#pragma once
|
||||
|
||||
#include "rtp_generic.hh"
|
||||
|
||||
namespace RTPOpus {
|
||||
struct OpusConfig {
|
||||
uint32_t samplerate;
|
||||
uint8_t channels;
|
||||
uint8_t configurationNumber;
|
||||
};
|
||||
|
||||
int pushOpusFrame(RTPConnection *conn, uint8_t *data, uint32_t dataLen, uint32_t timestamp);
|
||||
};
|
Loading…
Reference in New Issue