1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-13 03:41:55 +00:00

For #307, support publish RTC with passing opus. 4.0.24

This commit is contained in:
winlin 2020-04-30 10:57:03 +08:00
parent 99f9f566ba
commit 5ee5ef6ab2
7 changed files with 43 additions and 7 deletions

View file

@ -159,6 +159,7 @@ For previous versions, please read:
## V4 changes
* v4.0, 2020-04-30, For [#307][bug #307], support publish RTC with passing opus. 4.0.24
* v4.0, 2020-04-14, For [#307][bug #307], support sendmmsg, GSO and reuseport. 4.0.23
* v4.0, 2020-04-05, For [#307][bug #307], SRTP ASM only works with openssl-1.0, auto detect it. 4.0.22
* v4.0, 2020-04-04, Merge RTC and GB28181, with bugs fixed. 4.0.21

View file

@ -769,6 +769,7 @@ srs_error_t SrsRtcSenderThread::cycle()
SrsConsumer* consumer = NULL;
SrsAutoFree(SrsConsumer, consumer);
// TODO: FIXME: Dumps the SPS/PPS from gop cache, without other frames.
if ((err = source->create_consumer(NULL, consumer)) != srs_success) {
return srs_error_wrap(err, "rtc create consumer, source url=%s", req->get_stream_url().c_str());
}
@ -1968,7 +1969,25 @@ srs_error_t SrsRtcPublisher::collect_audio_frame()
for (size_t j = 0; j < frames.size(); ++j) {
SrsRtpSharedPacket* pkt = frames[j];
// TODO: FIXME: Write audio frame to source.
if (pkt->rtp_payload_size() > 0) {
SrsMessageHeader header;
header.message_type = RTMP_MSG_AudioMessage;
// TODO: FIXME: Maybe the tbn is not 90k.
header.timestamp = pkt->rtp_header.get_timestamp() / 90;
SrsSharedPtrMessage msg;
// TODO: FIXME: Check error.
msg.create(&header, NULL, 0);
SrsSample sample;
sample.size = pkt->rtp_payload_size();
sample.bytes = new char[sample.size];
memcpy((void*)sample.bytes, pkt->rtp_payload(), sample.size);
msg.set_extra_payloads(&sample, 1);
// TODO: FIXME: Check error.
source->on_rtc_audio(&msg);
}
srs_freep(pkt);
}
@ -2103,11 +2122,12 @@ srs_error_t SrsRtcPublisher::collect_video_frame()
stream->write_string(pps);
SrsMessageHeader header;
header.message_type = 9;
header.message_type = RTMP_MSG_VideoMessage;
// TODO: FIXME: Maybe the tbn is not 90k.
header.timestamp = timestamp / 90;
SrsCommonMessage* shared_video = new SrsCommonMessage();
SrsAutoFree(SrsCommonMessage, shared_video);
// TODO: FIXME: Check error.
shared_video->create(&header, reinterpret_cast<char*>(video_header), stream->pos());
srs_error_t e = source->on_video(shared_video);
if (e != srs_success) {
@ -2130,11 +2150,12 @@ srs_error_t SrsRtcPublisher::collect_video_frame()
frame_buffer[4] = 0x00;
SrsMessageHeader header;
header.message_type = 9;
header.message_type = RTMP_MSG_VideoMessage;
// TODO: FIXME: Maybe the tbn is not 90k.
header.timestamp = timestamp / 90;
SrsCommonMessage* shared_video = new SrsCommonMessage();
SrsAutoFree(SrsCommonMessage, shared_video);
// TODO: FIXME: Check error.
shared_video->create(&header, reinterpret_cast<char*>(frame_buffer), frame_buffer_index);
srs_error_t e = source->on_video(shared_video);
if (e != srs_success) {

View file

@ -1031,6 +1031,7 @@ srs_error_t SrsOriginHub::on_audio(SrsSharedPtrMessage* shared_audio)
SrsSharedPtrMessage* msg = shared_audio;
// TODO: FIXME: Support parsing OPUS for RTC.
if ((err = format->on_audio(msg)) != srs_success) {
return srs_error_wrap(err, "format consume audio");
}
@ -1058,6 +1059,7 @@ srs_error_t SrsOriginHub::on_audio(SrsSharedPtrMessage* shared_audio)
}
#ifdef SRS_RTC
// TODO: FIXME: Support parsing OPUS for RTC.
if ((err = rtc->on_audio(msg, format)) != srs_success) {
srs_warn("rtc: ignore audio error %s", srs_error_desc(err).c_str());
srs_error_reset(err);
@ -2761,4 +2763,11 @@ void SrsSource::request_keyframe()
rtc_publisher->request_keyframe();
}
}
srs_error_t SrsSource::on_rtc_audio(SrsSharedPtrMessage* audio)
{
// TODO: FIXME: Merge with on_audio.
// TODO: FIXME: Print key information.
return on_audio_imp(audio);
}
#endif

View file

@ -613,10 +613,12 @@ public:
virtual bool can_publish(bool is_edge);
virtual srs_error_t on_meta_data(SrsCommonMessage* msg, SrsOnMetaDataPacket* metadata);
public:
// TODO: FIXME: Use SrsSharedPtrMessage instead.
virtual srs_error_t on_audio(SrsCommonMessage* audio);
private:
virtual srs_error_t on_audio_imp(SrsSharedPtrMessage* audio);
public:
// TODO: FIXME: Use SrsSharedPtrMessage instead.
virtual srs_error_t on_video(SrsCommonMessage* video);
private:
virtual srs_error_t on_video_imp(SrsSharedPtrMessage* video);
@ -658,6 +660,7 @@ public:
void request_keyframe();
void set_rtc_publisher(SrsRtcPublisher* v) { rtc_publisher = v; }
// When got RTC audio message, which is encoded in opus.
// TODO: FIXME: Merge with on_audio.
srs_error_t on_rtc_audio(SrsSharedPtrMessage* audio);
#endif
};

View file

@ -24,6 +24,6 @@
#ifndef SRS_CORE_VERSION4_HPP
#define SRS_CORE_VERSION4_HPP
#define SRS_VERSION4_REVISION 23
#define SRS_VERSION4_REVISION 24
#endif

View file

@ -603,7 +603,7 @@ srs_error_t SrsFormat::on_audio(int64_t timestamp, char* data, int size)
srs_error_t err = srs_success;
if (!data || size <= 0) {
srs_trace("no audio present, ignore it.");
srs_info("no audio present, ignore it.");
return err;
}

View file

@ -158,6 +158,7 @@ public:
// 1byte.
// One byte field to represent the message type. A range of type IDs
// (1-7) are reserved for protocol control messages.
// For example, RTMP_MSG_AudioMessage or RTMP_MSG_VideoMessage.
int8_t message_type;
// 4bytes.
// Four-byte field that identifies the stream of the message. These
@ -245,6 +246,7 @@ public:
// 1byte.
// One byte field to represent the message type. A range of type IDs
// (1-7) are reserved for protocol control messages.
// For example, RTMP_MSG_AudioMessage or RTMP_MSG_VideoMessage.
int8_t message_type;
// Get the perfered cid(chunk stream id) which sendout over.
// set at decoding, and canbe used for directly send message,