Git Product home page Git Product logo

media-server's Introduction

media-server

media-server is a live streaming server based on brpc used in Live Streaming Service of Baidu Cloud.

Main features

Getting Started

Supported operating system: Linux, MacOSX.

  • Install brpc which is the main dependency of media-server
  • Compile media-server with cmake:
mkdir build && cd build && cmake .. && make -sj4
  • Run media-server as origin server with minimum configuration(the default port is 8079):
./output/bin/media_server

Then you can push/play stream from it.

Main options

Please run

./output/bin/media_server --help

to get all configurations in detail.

  • -proxy_to When not specified or empty, media-server runs in origin mode, which aggregates push(such as OBS, ffmpeg) and accepts play(such as cyberplayer, ffplay) requests.

  • -proxy_lb When -proxy_to is a naming service(such as http://...), you need to specify load balancing algorithm. The options are rr, random, la, c_murmurhash and c_md5. Read client load balancing for details.

  • -port Specifies the service port of media-server. Brpc is characterized by supporting all protocols on the same port, so this port can also be used for accessing the built-in service via http. Only ports in the range of 8000-9000 can be accessed by browsers, which means if the service port is external, be sure to configure -internal_port to prevent built-in service from leaking detailed service information.

  • -internal_port This port can be configured as a port that can only be accessed on the internal network. In this case, the -port port no longer provides built-in services, but will only be accessible through this port.

  • -retry_interval_ms When media-server runs in edge mode, push and pull requests to upstreams will be retried when error happens until clients no longer need. This option specifies the minimum interval for continuous retry, which is 1 second by default.

  • -share_play_connection When set to true, multiple streams connected to the same server will reuse the same rtmp connection in play.

  • -share_publish_connection When set to true, multiple streams connected to the same server will reuse the same rtmp connection in publish.

  • -timeout_ms Timeout period for creating a stream when media-server runs in edge mode. The default value is 1000ms.

  • -server_idle_timeout Connections without data transmission for so many seconds will be closed. The default value is -1(turned off).

  • -cdn_merge_to When this option is set, media-server starts two ports, one for external service request and the other for the aggregating request. Usually the aggregating server will be found using consistent hashing, which is used widely in cache service. This option is often used in cdn nodes.

  • -cdn_merge_lb The load balancing algorithm. Read the explanation written below -proxy_lb.

  • -flagfile media-server uses gflags options, which is specified by default in the command line and can also in file format during online deployment by using -flagfile.

Examples

Other docs

media-server's People

Contributors

jamesge avatar meibaogit avatar wasphin avatar zyearn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

media-server's Issues

我尝试回答下:

我尝试回答下:

  1. 问题 1:有没有 bug?
    iter_impl 出现 error 的时候,会调用 set_error ,阻止后续状态机的执行:
    if (iter_impl.has_error()) {
        set_error(iter_impl.error());
        iter_impl.run_the_rest_closure_with_error();
    }

do_commit 的时候会判断 fsm_caller 当前是否处于 error 状态:

void FSMCaller::do_committed(int64_t committed_index) {
    if (!_error.status().ok()) {
        return;
    }

FSMCaller 的 set_error 还会通知到 state machine 的 on_error 方法,表示一个不可恢复的错误发生,需要人工介入处理。整个状态机将停止,因此不会有后续的数据安全问题。并且需要强调 _last_applied_index 是内存状态, do_commit 最终存储的还是上一次的 index:

    int64_t last_applied_index = _last_applied_index.load(
                                        butil::memory_order_relaxed);
     .....
    _log_manager->set_applied_id(last_applied_id);

因此并不存在数据安全问题。

  1. 什么情况下会导致 iter_impl 出现 error ?

用户在 apply task 到状态机的时候可能遇到不可控的异常(比如网络或者文件磁盘沾满等 IO 问题),这种时候用户可以主动终止状态机继续执行,调用 set_error_and_rollback 方法回滚,人工介入处理,待错误恢复后继续执行状态机。

Originally posted by @killme2008 in baidu/braft#173 (comment)

cdn_merge_to的具体用法可以介绍下吗

如果有L0(边缘), L1(汇聚), L2(中心)
3种节点, 只需要L0 proxy_to L1 proxy_to L2, 便可以建一个分发网络
假设一个机房有20个L0, 这些L0的上层是同一个L1, 如果20个L0都向L1回源, 会有20份流量
我理解的cdn_merge_to, 应该角色上类似"机房代理", 也就是这个机房内的20个L0都向cdn_merge_to的节点回源, cdn_merge_to再向上层L1回源, 达到节省传输带宽的目的?
是这么理解吗?

编译失败

按照README的方法编译

media-server/src/http_streaming_service.cpp: In member function ‘virtual void ProxyHttp::Run()’:
media-server/src/http_streaming_service.cpp:584:54: error: cannot convert ‘butil::intrusive_ptr<brpc::ProgressiveAttachment>’ to ‘brpc::ProgressiveAttachment*’ in initialization
  584 |             _server_cntl->CreateProgressiveAttachment(brpc::FORCE_STOP);
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
      |                                                      |
      |                                                      butil::intrusive_ptr<brpc::ProgressiveAttachment>
media-server/src/http_streaming_service.cpp:866:46: error: cannot convert ‘butil::intrusive_ptr<brpc::ProgressiveAttachment>’ to ‘brpc::ProgressiveAttachment*’ in initialization
  866 |             cntl->CreateProgressiveAttachment(brpc::FORCE_STOP);
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
      |                                              |
      |                                              butil::intrusive_ptr<brpc::ProgressiveAttachment>
make[2]: *** [src/CMakeFiles/media_server.dir/build.make:155: src/CMakeFiles/media_server.dir/http_streaming_service.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:140: src/CMakeFiles/media_server.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

windows 10 wsl2 linux找不到brpc

确定 pthread_create 是否存在失败,输出如下:
更改目录:/home/sudosocourus/work/media-server/build/CMakeFiles/CMakeTmp

运行构建命令:"/usr/bin/make" "cmTC_d96c9/fast"
/usr/bin/make -f CMakeFiles/cmTC_d96c9.dir/build.make CMakeFiles/cmTC_d96c9.dir/build
make[1]: 进入目录'/home/sudosocourus/work/media-server/build/CMakeFiles/CMakeTmp'
构建 C 对象 CMakeFiles/cmTC_d96c9.dir/CheckSymbolExists.c.o
/usr/bin/cc -o CMakeFiles/cmTC_d96c9.dir/CheckSymbolExists.c.o -c /home/sudosocourus/work/media-server/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c
链接 C 可执行文件 cmTC_d96c9
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_d96c9.dir/link.txt --verbose=1
/usr/bin/cc -rdynamic CMakeFiles/cmTC_d96c9.dir/CheckSymbolExists.c.o -o cmTC_d96c9
CMakeFiles/cmTC_d96c9.dir/CheckSymbolExists.c.o:在函数“main”中:
CheckSymbolExists.c:(.text+0x1b): 未定义对“pthread_create”的引用
collect2:错误:ld 返回 1 个退出状态
CMakeFiles/cmTC_d96c9.dir/build.make:97:目标“cmTC_d96c9”的配方失败
make[1]: *** [cmTC_d96c9] 错误 1
make[1]: 离开目录 '/home/sudosocourus/work/media-server/build/CMakeFiles/CMakeTmp'
Makefile:126: 目标“cmTC_d96c9/fast”的配方失败
制作:*** [cmTC_d96c9/fast] 错误 2

文件/home/sudosocourus/work/media-server/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
/* */
#include <pthread.h>

int main(int argc, char** argv)
{
  (无效)argv;
#ifndef pthread_create
  返回 ((int*)(&pthread_create))[argc];
#别的
  (无效)argc;
  返回0;
#万一
}

确定 pthreads 中是否存在函数 pthread_create 失败,输出如下:
更改目录:/home/sudosocourus/work/media-server/build/CMakeFiles/CMakeTmp

运行构建命令:"/usr/bin/make" "cmTC_464c2/fast"
/usr/bin/make -f CMakeFiles/cmTC_464c2.dir/build.make CMakeFiles/cmTC_464c2.dir/build
make[1]: 进入目录'/home/sudosocourus/work/media-server/build/CMakeFiles/CMakeTmp'
构建 C 对象 CMakeFiles/cmTC_464c2.dir/CheckFunctionExists.c.o
/usr/bin/cc -DCHECK_FUNCTION_EXISTS=pthread_create -o CMakeFiles/cmTC_464c2.dir/CheckFunctionExists.c.o -c /usr/share/cmake-3.10/Modules/CheckFunctionExists.c
链接 C 可执行文件 cmTC_464c2
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_464c2.dir/link.txt --verbose=1
/usr/bin/cc -DCHECK_FUNCTION_EXISTS=pthread_create -rdynamic CMakeFiles/cmTC_464c2.dir/CheckFunctionExists.c.o -o cmTC_464c2 -lpthreads
/usr/bin/ld: 找不到 -lpthreads
collect2:错误:ld 返回 1 个退出状态
CMakeFiles/cmTC_464c2.dir/build.make:97:目标“cmTC_464c2”的配方失败
make[1]: *** [cmTC_464c2] 错误 1
make[1]: 离开目录 '/home/sudosocourus/work/media-server/build/CMakeFiles/CMakeTmp'
Makefile:126: 目标“cmTC_464c2/fast”的配方失败
制作:*** [cmTC_464c2/fast] 错误 2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.