2014-03-01 07:59:55 +00:00
|
|
|
/*
|
|
|
|
The MIT License (MIT)
|
|
|
|
|
2014-12-31 12:32:09 +00:00
|
|
|
Copyright (c) 2013-2015 winlin
|
2014-03-01 07:59:55 +00:00
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
|
|
this software and associated documentation files (the "Software"), to deal in
|
|
|
|
the Software without restriction, including without limitation the rights to
|
|
|
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
|
|
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
|
|
subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in all
|
|
|
|
copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
|
|
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
|
|
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SRS_RTMP_PROTOCOL_CONSTS_HPP
|
|
|
|
#define SRS_RTMP_PROTOCOL_CONSTS_HPP
|
|
|
|
|
|
|
|
/*
|
2015-01-23 02:07:20 +00:00
|
|
|
#include <srs_rtmp_utility.hpp>
|
2014-03-01 07:59:55 +00:00
|
|
|
*/
|
|
|
|
#include <srs_core.hpp>
|
|
|
|
|
2014-06-08 05:03:03 +00:00
|
|
|
#include <string>
|
|
|
|
|
2014-07-20 05:11:53 +00:00
|
|
|
#include <srs_kernel_consts.hpp>
|
2014-03-01 07:59:55 +00:00
|
|
|
|
2014-12-06 11:56:06 +00:00
|
|
|
class SrsMessageHeader;
|
2015-01-31 11:46:55 +00:00
|
|
|
class SrsSharedPtrMessage;
|
2014-11-07 15:07:31 +00:00
|
|
|
|
2014-07-06 09:43:08 +00:00
|
|
|
/**
|
|
|
|
* parse the tcUrl, output the schema, host, vhost, app and port.
|
|
|
|
* @param tcUrl, the input tcUrl, for example,
|
|
|
|
* rtmp://192.168.1.10:19350/live?vhost=vhost.ossrs.net
|
|
|
|
* @param schema, for example, rtmp
|
|
|
|
* @param host, for example, 192.168.1.10
|
|
|
|
* @param vhost, for example, vhost.ossrs.net.
|
|
|
|
* vhost default to host, when user not set vhost in query of app.
|
|
|
|
* @param app, for example, live
|
|
|
|
* @param port, for example, 19350
|
|
|
|
* default to 1935 if not specified.
|
2014-07-13 08:10:06 +00:00
|
|
|
* param param, for example, vhost=vhost.ossrs.net
|
2014-07-06 09:43:08 +00:00
|
|
|
*/
|
2014-06-29 03:45:31 +00:00
|
|
|
extern void srs_discovery_tc_url(
|
|
|
|
std::string tcUrl,
|
|
|
|
std::string& schema, std::string& host, std::string& vhost,
|
2014-07-13 08:10:06 +00:00
|
|
|
std::string& app, std::string& port, std::string& param
|
2014-06-29 03:45:31 +00:00
|
|
|
);
|
|
|
|
|
2014-07-06 09:43:08 +00:00
|
|
|
/**
|
|
|
|
* resolve the vhost in query string
|
2014-07-13 08:10:06 +00:00
|
|
|
* @pram vhost, update the vhost if query contains the vhost.
|
2014-07-06 09:43:08 +00:00
|
|
|
* @param app, may contains the vhost in query string format:
|
|
|
|
* app?vhost=request_vhost
|
|
|
|
* app...vhost...request_vhost
|
2014-07-13 08:10:06 +00:00
|
|
|
* @param param, the query, for example, ?vhost=xxx
|
2014-07-06 09:43:08 +00:00
|
|
|
*/
|
2014-07-13 08:10:06 +00:00
|
|
|
extern void srs_vhost_resolve(std::string& vhost, std::string& app, std::string& param);
|
2014-03-01 07:59:55 +00:00
|
|
|
|
2014-07-06 09:43:08 +00:00
|
|
|
/**
|
|
|
|
* generate ramdom data for handshake.
|
|
|
|
*/
|
2014-03-19 06:58:29 +00:00
|
|
|
extern void srs_random_generate(char* bytes, int size);
|
|
|
|
|
2014-07-06 09:43:08 +00:00
|
|
|
/**
|
|
|
|
* generate the tcUrl.
|
2014-07-13 08:10:06 +00:00
|
|
|
* @param param, the app parameters in tcUrl. for example, ?key=xxx,vhost=xxx
|
2014-07-06 09:43:08 +00:00
|
|
|
* @return the tcUrl generated from ip/vhost/app/port.
|
|
|
|
* @remark when vhost equals to __defaultVhost__, use ip as vhost.
|
|
|
|
* @remark ignore port if port equals to default port 1935.
|
|
|
|
*/
|
|
|
|
extern std::string srs_generate_tc_url(
|
2014-07-13 08:10:06 +00:00
|
|
|
std::string ip, std::string vhost, std::string app, std::string port,
|
|
|
|
std::string param
|
2014-07-06 09:43:08 +00:00
|
|
|
);
|
2014-06-29 02:03:29 +00:00
|
|
|
|
2014-07-05 03:10:42 +00:00
|
|
|
/**
|
|
|
|
* compare the memory in bytes.
|
2014-07-06 09:43:08 +00:00
|
|
|
* @return true if completely equal; otherwise, false.
|
2014-07-05 03:10:42 +00:00
|
|
|
*/
|
|
|
|
extern bool srs_bytes_equals(void* pa, void* pb, int size);
|
|
|
|
|
2014-12-06 11:56:06 +00:00
|
|
|
/**
|
2014-12-07 03:25:05 +00:00
|
|
|
* generate the c0 chunk header for msg.
|
|
|
|
* @param cache, the cache to write header.
|
|
|
|
* @param nb_cache, the size of cache.
|
|
|
|
* @return the size of header. 0 if cache not enough.
|
2014-12-06 11:56:06 +00:00
|
|
|
*/
|
2014-12-07 03:25:05 +00:00
|
|
|
extern int srs_chunk_header_c0(
|
|
|
|
int perfer_cid, u_int32_t timestamp, int32_t payload_length,
|
|
|
|
int8_t message_type, int32_t stream_id,
|
|
|
|
char* cache, int nb_cache
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* generate the c3 chunk header for msg.
|
|
|
|
* @param cache, the cache to write header.
|
|
|
|
* @param nb_cache, the size of cache.
|
|
|
|
* @return the size of header. 0 if cache not enough.
|
|
|
|
*/
|
|
|
|
extern int srs_chunk_header_c3(
|
|
|
|
int perfer_cid, u_int32_t timestamp,
|
|
|
|
char* cache, int nb_cache
|
|
|
|
);
|
2014-12-06 11:56:06 +00:00
|
|
|
|
2015-01-31 11:46:55 +00:00
|
|
|
/**
|
|
|
|
* create shared ptr message from bytes.
|
|
|
|
* @param data the packet bytes. user should never free it.
|
|
|
|
* @param ppmsg output the shared ptr message. user should free it.
|
|
|
|
*/
|
|
|
|
extern int srs_rtmp_create_msg(char type, u_int32_t timestamp, char* data, int size, int stream_id, SrsSharedPtrMessage** ppmsg);
|
|
|
|
|
2014-03-01 07:59:55 +00:00
|
|
|
#endif
|
2014-08-02 14:18:39 +00:00
|
|
|
|