Skip to content

Commit

Permalink
hls支持opus
Browse files Browse the repository at this point in the history
  • Loading branch information
xia-chu committed Aug 1, 2020
1 parent df49d6a commit a9b0ca9
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 64 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
- 提供完整的[MediaServer](https://github.com/xia-chu/ZLMediaKit/tree/master/server)服务器,可以免开发直接部署为商用服务器。
- 提供完善的[restful api](https://github.com/xia-chu/ZLMediaKit/wiki/MediaServer%E6%94%AF%E6%8C%81%E7%9A%84HTTP-API)以及[web hook](https://github.com/xia-chu/ZLMediaKit/wiki/MediaServer%E6%94%AF%E6%8C%81%E7%9A%84HTTP-HOOK-API),支持丰富的业务逻辑。
- 打通了视频监控协议栈与直播协议栈,对RTSP/RTMP支持都很完善。
- 全面支持H265/H264/AAC/G711。
- 全面支持H265/H264/AAC/G711/OPUS

## 项目定位

Expand Down Expand Up @@ -55,7 +55,7 @@
- 支持HLS文件生成,自带HTTP文件服务器
- 通过cookie追踪技术,可以模拟HLS播放为长连接,可以实现HLS按需拉流、播放统计等业务
- 支持HLS播发器,支持拉流HLS转rtsp/rtmp/mp4
- 支持H264/H265/AAC/G711编码
- 支持H264/H265/AAC/G711/OPUS编码

- HTTP[S]与WebSocket
- 服务器支持`目录索引生成`,`文件下载`,`表单提交请求`
Expand All @@ -68,7 +68,7 @@

- GB28181与RTP推流
- 支持UDP/TCP国标RTP(PS或TS)推流,可以转换成RTSP/RTMP/HLS等协议
- 支持H264/H265/AAC/G711编码
- 支持H264/H265/AAC/G711/OPUS编码

- MP4点播与录制
- 支持录制为FLV/HLS/MP4
Expand Down
62 changes: 2 additions & 60 deletions README_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
- RTSP[S] player and pusher.
- RTP Transport : `rtp over udp` `rtp over tcp` `rtp over http` `rtp udp multicast` .
- Basic/Digest/Url Authentication.
- H264/H265/AAC/G711 codec.
- H265/H264/AAC/G711/OPUS codec.
- Recorded as mp4.
- Vod of mp4.

- RTMP[S]
- RTMP[S] server,support player and pusher.
- RTMP[S] player and pusher.
- Support HTTP-FLV player.
- H264/H265/AAC/G711 codec.
- H265/H264/AAC/G711/OPUS codec.
- Recorded as flv or mp4.
- Vod of mp4.
- support [RTMP-H265](https://github.com/ksvc/FFmpeg/wiki)
Expand Down Expand Up @@ -56,62 +56,6 @@
- Support TS / PS streaming push through RTP,and it can be converted to RTSP / RTMP / HLS / FLV.
- Support real-time online screenshot http api.


- Protocol conversion:

| protocol/codec | H264 | H265 | AAC | other |
| :------------------------------: | :--: | :--: | :--: | :---: |
| RTSP[S] --> RTMP/HTTP[S]-FLV/FLV | Y | Y | Y | N |
| RTMP --> RTSP[S] | Y | Y | Y | N |
| RTSP[S] --> HLS | Y | Y | Y | N |
| RTMP --> HLS | Y | Y | Y | N |
| RTSP[S] --> MP4 | Y | Y | Y | N |
| RTMP --> MP4 | Y | Y | Y | N |
| MP4 --> RTSP[S] | Y | Y | Y | N |
| MP4 --> RTMP | Y | Y | Y | N |
| HLS --> RTSP/RTMP/MP4 | Y | Y | Y | N |

- Stream generation:

| feature/codec | H264 | H265 | AAC | other |
| :-----------: | :--: | :--: | :--: | :---: |
| RTSP[S] push | Y | Y | Y | Y |
| RTSP proxy | Y | Y | Y | Y |
| RTMP push | Y | Y | Y | Y |
| RTMP proxy | Y | Y | Y | Y |

- RTP transport:

| feature/transport | tcp | udp | http | udp_multicast |
| :-----------------: | :--: | :--: | :--: | :-----------: |
| RTSP[S] Play Server | Y | Y | Y | Y |
| RTSP[S] Push Server | Y | Y | N | N |
| RTSP Player | Y | Y | N | Y |
| RTSP Pusher | Y | Y | N | N |


- Server supported:

| Server | Y/N |
| :-----------------: | :--: |
| RTSP[S] Play Server | Y |
| RTSP[S] Push Server | Y |
| RTMP | Y |
| HTTP[S]/WebSocket[S] | Y |

- Client supported:

| Client | Y/N |
| :---------: | :--: |
| RTSP Player | Y |
| RTSP Pusher | Y |
| RTMP Player | Y |
| RTMP Pusher | Y |
| HTTP[S] | Y |
| WebSocket[S] | Y |
| HLS player | Y |


## System Requirements

- Compiler support c++11,GCC4.8/Clang3.3/VC2015 or above.
Expand Down Expand Up @@ -191,8 +135,6 @@ git submodule update --init
```




### Build on Android

Now you can open android sudio project in `Android` folder,this is a `aar library` and damo project.
Expand Down
5 changes: 5 additions & 0 deletions src/Record/TsMuxer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ void TsMuxer::addTrack(const Track::Ptr &track) {
break;
}

case CodecOpus: {
_codec_to_trackid[track->getCodecId()].track_id = mpeg_ts_add_stream(_context, PSI_STREAM_AUDIO_OPUS, nullptr, 0);
break;
}

default: WarnL << "mpeg-ts 不支持该编码格式,已忽略:" << track->getCodecName(); break;
}

Expand Down
20 changes: 20 additions & 0 deletions src/Rtp/Decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "Extension/H265.h"
#include "Extension/AAC.h"
#include "Extension/G711.h"
#include "Extension/Opus.h"

#if defined(ENABLE_RTPPROXY) || defined(ENABLE_HLS)
#include "mpeg-ts-proto.h"
Expand Down Expand Up @@ -91,6 +92,7 @@ static const char *getCodecName(int codec_id) {
SWITCH_CASE(PSI_STREAM_AUDIO_G722);
SWITCH_CASE(PSI_STREAM_AUDIO_G723);
SWITCH_CASE(PSI_STREAM_AUDIO_G729);
SWITCH_CASE(PSI_STREAM_AUDIO_OPUS);
default : return "unknown codec";
}
}
Expand Down Expand Up @@ -198,6 +200,24 @@ void DecoderImp::onDecode(int stream,int codecid,int flags,int64_t pts,int64_t d
onFrame(std::make_shared<FrameFromPtr>(codec, (char *) data, bytes, dts));
break;
}

case PSI_STREAM_AUDIO_OPUS: {
if (!_codecid_audio) {
//获取到音频
_codecid_audio = codecid;
InfoL << "got audio track: opus";
auto track = std::make_shared<OpusTrack>();
onTrack(track);
}

if (codecid != _codecid_audio) {
WarnL << "audio track change to opus from codecid:" << getCodecName(_codecid_audio);
return;
}
onFrame(std::make_shared<FrameFromPtr>(CodecOpus, (char *) data, bytes, dts));
break;
}

default:
if(codecid != 0){
WarnL<< "unsupported codec type:" << getCodecName(codecid) << " " << (int)codecid;
Expand Down

0 comments on commit a9b0ca9

Please sign in to comment.