winlin

srs-librtmp define interfaces

... ... @@ -42,19 +42,21 @@ echo "" >> $SRS_AUTO_HEADERS_H
echo "generate Makefile"
SRS_MAKEFILE="Makefile"
cat << END > ${SRS_MAKEFILE}
.PHONY: default help clean server bandwidth librtmp _prepare_dir
default: server bandwidth librtmp
.PHONY: default help clean server bandwidth librtmp librtmp-sample _prepare_dir
default: server bandwidth librtmp librtmp-sample
help:
@echo "Usage: make <help>|<clean>|<server>|<bandwidth>|<librtmp>"
@echo "Usage: make <help>|<clean>|<server>|<bandwidth>|<librtmp>|<librtmp-sample>"
@echo " help display this help menu"
@echo " clean cleanup project"
@echo " server build the srs(simple rtmp server) over st(state-threads)"
@echo " bandwidth build the bandwidth test client tool."
@echo " librtmp build the client publish/play library."
@echo " librtmp-sample build the srs-librtmp sample"
clean:
(rm -f Makefile; cd ${SRS_OBJS}; rm -rf srs bandwidth Makefile *.hpp src st_*_load research include lib)
(cd research/librtmp; make clean)
server: _prepare_dir
@echo "build the srs(simple rtmp server) over st(state-threads)"
... ... @@ -68,6 +70,11 @@ librtmp: _prepare_dir
@echo "build the client publish/play library."
\$(MAKE) -f ${SRS_OBJS}/${SRS_MAKEFILE} librtmp
librtmp-sample:
@echo "build the srs-librtmp sample"
(cd research/librtmp; make)
@echo "srs-librtmp sample build success"
# the ./configure will generate it.
_prepare_dir:
@mkdir -p ${SRS_OBJS}
... ... @@ -140,8 +147,7 @@ CORE_OBJS="${MODULE_OBJS[@]}"
MODULE_ID="KERNEL"
MODULE_DEPENDS=("CORE")
ModuleLibIncs=(${SRS_OBJS})
MODULE_FILES=("srs_kernel_error" "srs_kernel_log" "srs_kernel_reload" "srs_kernel_stream"
"srs_kernel_buffer")
MODULE_FILES=("srs_kernel_error" "srs_kernel_log" "srs_kernel_stream" "srs_kernel_buffer")
MODULE_DIR="src/kernel" . auto/modules.sh
KERNEL_OBJS="${MODULE_OBJS[@]}"
#
... ... @@ -161,7 +167,7 @@ ModuleLibIncs=(${LibSTRoot} ${LibHttpParserRoot} ${SRS_OBJS})
MODULE_FILES=("srs_core_server" "srs_core_conn" "srs_core_client" "srs_core_socket" "srs_core_source"
"srs_core_codec" "srs_core_refer" "srs_core_hls" "srs_core_forward" "srs_core_encoder"
"srs_core_http" "srs_core_thread" "srs_core_bandwidth" "srs_core_st" "srs_core_log"
"srs_core_config" "srs_core_pithy_print")
"srs_core_config" "srs_core_pithy_print" "srs_core_reload")
MODULE_DIR="src/app" . auto/modules.sh
APP_OBJS="${MODULE_OBJS[@]}"
#
... ...
... ... @@ -29,9 +29,33 @@ gcc srs_play.c ../../objs/lib/srs_librtmp.a -g -O0 -lstdc++ -o srs_play
int main(int argc, char** argv)
{
srs_rtmp_t rtmp;
printf("suck rtmp stream like rtmpdump\n");
printf("srs(simple-rtmp-server) client librtmp library.\n");
printf("version: %d.%d.%d\n", srs_version_major(), srs_version_minor(), srs_version_revision());
rtmp = srs_rtmp_create("rtmp://127.0.0.1/live/livestream");
if (srs_simple_handshake(rtmp) != 0) {
printf("simple handshake failed.\n");
return -1;
}
printf("simple handshake success\n");
if (srs_connect_app(rtmp) != 0) {
printf("connect vhost/app failed.\n");
return -1;
}
printf("connect vhost/app success\n");
if (srs_play_stream(rtmp) != 0) {
printf("play stream failed.\n");
return -1;
}
printf("play stream success\n");
srs_rtmp_destroy(rtmp);
return 0;
}
... ...
... ... @@ -29,9 +29,33 @@ gcc srs_publish.c ../../objs/lib/srs_librtmp.a -g -O0 -lstdc++ -o srs_publish
int main(int argc, char** argv)
{
srs_rtmp_t rtmp;
printf("publish rtmp stream to server like FMLE/FFMPEG/Encoder\n");
printf("srs(simple-rtmp-server) client librtmp library.\n");
printf("version: %d.%d.%d\n", srs_version_major(), srs_version_minor(), srs_version_revision());
rtmp = srs_rtmp_create("rtmp://127.0.0.1/live/livestream");
if (srs_simple_handshake(rtmp) != 0) {
printf("simple handshake failed.\n");
return -1;
}
printf("simple handshake success\n");
if (srs_connect_app(rtmp) != 0) {
printf("connect vhost/app failed.\n");
return -1;
}
printf("connect vhost/app success\n");
if (srs_publish_stream(rtmp) != 0) {
printf("publish stream failed.\n");
return -1;
}
printf("publish stream success\n");
srs_rtmp_destroy(rtmp);
return 0;
}
... ...
... ... @@ -32,7 +32,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_core_st.hpp>
#include <srs_core_conn.hpp>
#include <srs_kernel_reload.hpp>
#include <srs_core_reload.hpp>
class SrsRtmp;
class SrsRequest;
... ...
... ... @@ -32,7 +32,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <vector>
#include <string>
#include <srs_kernel_reload.hpp>
#include <srs_core_reload.hpp>
// default vhost for rtmp
#define RTMP_VHOST_DEFAULT "__defaultVhost__"
... ...
... ... @@ -28,7 +28,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_kernel_log.hpp>
#include <srs_core_config.hpp>
#include <srs_kernel_reload.hpp>
#include <srs_core_reload.hpp>
#include <srs_kernel_error.hpp>
#define SRS_STAGE_DEFAULT_INTERVAL_MS 1200
... ...
... ... @@ -21,7 +21,7 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <srs_kernel_reload.hpp>
#include <srs_core_reload.hpp>
using namespace std;
... ...
... ... @@ -25,7 +25,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define SRS_KERNEL_RELOAD_HPP
/*
#include <srs_kernel_reload.hpp>
#include <srs_core_reload.hpp>
*/
#include <srs_core.hpp>
... ...
... ... @@ -33,7 +33,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <vector>
#include <srs_core_st.hpp>
#include <srs_kernel_reload.hpp>
#include <srs_core_reload.hpp>
#include <srs_core_thread.hpp>
class SrsServer;
... ...
... ... @@ -35,7 +35,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <string>
#include <srs_core_st.hpp>
#include <srs_kernel_reload.hpp>
#include <srs_core_reload.hpp>
class SrsSource;
class SrsCommonMessage;
... ...
... ... @@ -25,6 +25,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <stdlib.h>
#include <string>
using namespace std;
#include <srs_kernel_error.hpp>
#include <srs_protocol_rtmp.hpp>
/**
... ... @@ -49,6 +53,7 @@ public:
*/
struct Context
{
std::string url;
SrsRtmpClient* rtmp;
SimpleSocketStream* stream;
int stream_id;
... ... @@ -68,8 +73,9 @@ struct Context
extern "C"{
#endif
srs_rtmp_t srs_rtmp_create(){
srs_rtmp_t srs_rtmp_create(const char* url){
Context* context = new Context();
context->url = url;
return context;
}
... ... @@ -79,6 +85,31 @@ void srs_rtmp_destroy(srs_rtmp_t rtmp){
srs_freep(context);
}
int srs_simple_handshake(srs_rtmp_t rtmp)
{
return ERROR_SUCCESS;
}
int srs_complex_handshake(srs_rtmp_t rtmp)
{
return ERROR_SUCCESS;
}
int srs_connect_app(srs_rtmp_t rtmp)
{
return ERROR_SUCCESS;
}
int srs_play_stream(srs_rtmp_t rtmp)
{
return ERROR_SUCCESS;
}
int srs_publish_stream(srs_rtmp_t rtmp)
{
return ERROR_SUCCESS;
}
int srs_version_major()
{
return ::atoi(VERSION_MAJOR);
... ...
... ... @@ -36,15 +36,58 @@ extern "C"{
typedef void* srs_rtmp_t;
/**
* create a rtmp protocol stack.
* create/destroy a rtmp protocol stack.
* @url rtmp url, for example:
* rtmp://127.0.0.1/live/livestream
* @return a rtmp handler, or NULL if error occured.
*/
srs_rtmp_t srs_rtmp_create();
srs_rtmp_t srs_rtmp_create(const char* url);
void srs_rtmp_destroy(srs_rtmp_t rtmp);
/**
* close a rtmp protocl stack.
* handshake with server
* category: publish/play
* previous: rtmp-create
* next: connect-app
* @return 0, success; otherwise, failed.
*/
void srs_rtmp_destroy(srs_rtmp_t rtmp);
/**
* simple handshake specifies in rtmp 1.0,
* not depends on ssl.
*/
int srs_simple_handshake(srs_rtmp_t rtmp);
/**
* complex handshake is specified by adobe Flash player,
* depends on ssl, user must link libssl.a and libcrypt.a
*/
int srs_complex_handshake(srs_rtmp_t rtmp);
/**
* connect to rtmp vhost/app
* category: publish/play
* previous: handshake
* next: publish or play
* @return 0, success; otherwise, failed.
*/
int srs_connect_app(srs_rtmp_t rtmp);
/**
* play a live/vod stream.
* category: play
* previous: connect-app
* next: destroy
* @return 0, success; otherwise, failed.
*/
int srs_play_stream(srs_rtmp_t rtmp);
/**
* publish a live stream.
* category: publish
* previous: connect-app
* next: destroy
* @return 0, success; otherwise, failed.
*/
int srs_publish_stream(srs_rtmp_t rtmp);
/**
* get protocol stack version
... ...
... ... @@ -19,8 +19,6 @@ file
..\kernel\srs_kernel_error.cpp,
..\kernel\srs_kernel_log.hpp,
..\kernel\srs_kernel_log.cpp,
..\kernel\srs_kernel_reload.hpp,
..\kernel\srs_kernel_reload.cpp,
..\kernel\srs_kernel_stream.hpp,
..\kernel\srs_kernel_stream.cpp,
rtmp-protocol readonly separator,
... ... @@ -59,6 +57,8 @@ file
..\app\srs_core_log.cpp,
..\app\srs_core_refer.hpp,
..\app\srs_core_refer.cpp,
..\app\srs_core_reload.hpp,
..\app\srs_core_reload.cpp,
..\app\srs_core_pithy_print.hpp,
..\app\srs_core_pithy_print.cpp,
..\app\srs_core_thread.hpp,
... ...