正在显示
1 个修改的文件
包含
47 行增加
和
45 行删除
| @@ -1002,80 +1002,82 @@ typedef void* srs_hijack_io_t; | @@ -1002,80 +1002,82 @@ typedef void* srs_hijack_io_t; | ||
| 1002 | // which use librtmp but use its own io(use st also). | 1002 | // which use librtmp but use its own io(use st also). |
| 1003 | #ifdef SRS_HIJACK_IO | 1003 | #ifdef SRS_HIJACK_IO |
| 1004 | /** | 1004 | /** |
| 1005 | - * create hijack. | ||
| 1006 | - * @return NULL for error; otherwise, ok. | ||
| 1007 | - */ | 1005 | + * create hijack. |
| 1006 | + * @return NULL for error; otherwise, ok. | ||
| 1007 | + */ | ||
| 1008 | extern srs_hijack_io_t srs_hijack_io_create(); | 1008 | extern srs_hijack_io_t srs_hijack_io_create(); |
| 1009 | /** | 1009 | /** |
| 1010 | - * destroy the context, user must close the socket. | ||
| 1011 | - */ | 1010 | + * destroy the context, user must close the socket. |
| 1011 | + */ | ||
| 1012 | extern void srs_hijack_io_destroy(srs_hijack_io_t ctx); | 1012 | extern void srs_hijack_io_destroy(srs_hijack_io_t ctx); |
| 1013 | /** | 1013 | /** |
| 1014 | - * create socket, not connect yet. | ||
| 1015 | - * @param owner, the rtmp context which create this socket. | ||
| 1016 | - * @return 0, success; otherswise, failed. | ||
| 1017 | - */ | 1014 | + * create socket, not connect yet. |
| 1015 | + * @param owner, the rtmp context which create this socket. | ||
| 1016 | + * @return 0, success; otherswise, failed. | ||
| 1017 | + */ | ||
| 1018 | extern int srs_hijack_io_create_socket(srs_hijack_io_t ctx, srs_rtmp_t owner); | 1018 | extern int srs_hijack_io_create_socket(srs_hijack_io_t ctx, srs_rtmp_t owner); |
| 1019 | /** | 1019 | /** |
| 1020 | - * connect socket at server_ip:port. | ||
| 1021 | - * @return 0, success; otherswise, failed. | ||
| 1022 | - */ | 1020 | + * connect socket at server_ip:port. |
| 1021 | + * @return 0, success; otherswise, failed. | ||
| 1022 | + */ | ||
| 1023 | extern int srs_hijack_io_connect(srs_hijack_io_t ctx, const char* server_ip, int port); | 1023 | extern int srs_hijack_io_connect(srs_hijack_io_t ctx, const char* server_ip, int port); |
| 1024 | /** | 1024 | /** |
| 1025 | - * read from socket. | ||
| 1026 | - * @return 0, success; otherswise, failed. | ||
| 1027 | - */ | 1025 | + * read from socket. |
| 1026 | + * @return 0, success; otherswise, failed. | ||
| 1027 | + */ | ||
| 1028 | extern int srs_hijack_io_read(srs_hijack_io_t ctx, void* buf, size_t size, ssize_t* nread); | 1028 | extern int srs_hijack_io_read(srs_hijack_io_t ctx, void* buf, size_t size, ssize_t* nread); |
| 1029 | /** | 1029 | /** |
| 1030 | - * set the socket recv timeout in ms. | ||
| 1031 | - * @return 0, success; otherswise, failed. | ||
| 1032 | - */ | 1030 | + * set the socket recv timeout in ms. |
| 1031 | + * @return 0, success; otherswise, failed. | ||
| 1032 | + */ | ||
| 1033 | extern int srs_hijack_io_set_recv_timeout(srs_hijack_io_t ctx, int64_t tm); | 1033 | extern int srs_hijack_io_set_recv_timeout(srs_hijack_io_t ctx, int64_t tm); |
| 1034 | /** | 1034 | /** |
| 1035 | - * get the socket recv timeout. | ||
| 1036 | - * @return 0, success; otherswise, failed. | ||
| 1037 | - */ | 1035 | + * get the socket recv timeout. |
| 1036 | + * @return 0, success; otherswise, failed. | ||
| 1037 | + */ | ||
| 1038 | extern int64_t srs_hijack_io_get_recv_timeout(srs_hijack_io_t ctx); | 1038 | extern int64_t srs_hijack_io_get_recv_timeout(srs_hijack_io_t ctx); |
| 1039 | /** | 1039 | /** |
| 1040 | - * get the socket recv bytes. | ||
| 1041 | - * @return 0, success; otherswise, failed. | ||
| 1042 | - */ | 1040 | + * get the socket recv bytes. |
| 1041 | + * @return 0, success; otherswise, failed. | ||
| 1042 | + */ | ||
| 1043 | extern int64_t srs_hijack_io_get_recv_bytes(srs_hijack_io_t ctx); | 1043 | extern int64_t srs_hijack_io_get_recv_bytes(srs_hijack_io_t ctx); |
| 1044 | /** | 1044 | /** |
| 1045 | - * set the socket send timeout in ms. | ||
| 1046 | - * @return 0, success; otherswise, failed. | ||
| 1047 | - */ | 1045 | + * set the socket send timeout in ms. |
| 1046 | + * @return 0, success; otherswise, failed. | ||
| 1047 | + */ | ||
| 1048 | extern int srs_hijack_io_set_send_timeout(srs_hijack_io_t ctx, int64_t tm); | 1048 | extern int srs_hijack_io_set_send_timeout(srs_hijack_io_t ctx, int64_t tm); |
| 1049 | /** | 1049 | /** |
| 1050 | - * get the socket send timeout. | ||
| 1051 | - * @return 0, success; otherswise, failed. | ||
| 1052 | - */ | 1050 | + * get the socket send timeout. |
| 1051 | + * @return 0, success; otherswise, failed. | ||
| 1052 | + */ | ||
| 1053 | extern int64_t srs_hijack_io_get_send_timeout(srs_hijack_io_t ctx); | 1053 | extern int64_t srs_hijack_io_get_send_timeout(srs_hijack_io_t ctx); |
| 1054 | /** | 1054 | /** |
| 1055 | - * get the socket send bytes. | ||
| 1056 | - * @return 0, success; otherswise, failed. | ||
| 1057 | - */ | 1055 | + * get the socket send bytes. |
| 1056 | + * @return 0, success; otherswise, failed. | ||
| 1057 | + */ | ||
| 1058 | extern int64_t srs_hijack_io_get_send_bytes(srs_hijack_io_t ctx); | 1058 | extern int64_t srs_hijack_io_get_send_bytes(srs_hijack_io_t ctx); |
| 1059 | /** | 1059 | /** |
| 1060 | - * writev of socket. | ||
| 1061 | - * @return 0, success; otherswise, failed. | ||
| 1062 | - */ | 1060 | + * writev of socket. |
| 1061 | + * @return 0, success; otherswise, failed. | ||
| 1062 | + * @remark We assume that the writev always write all data to peer, like what ST or block-socket done. | ||
| 1063 | + */ | ||
| 1063 | extern int srs_hijack_io_writev(srs_hijack_io_t ctx, const iovec *iov, int iov_size, ssize_t* nwrite); | 1064 | extern int srs_hijack_io_writev(srs_hijack_io_t ctx, const iovec *iov, int iov_size, ssize_t* nwrite); |
| 1064 | /** | 1065 | /** |
| 1065 | - * whether the timeout is never timeout in ms. | ||
| 1066 | - * @return 0, success; otherswise, failed. | ||
| 1067 | - */ | 1066 | + * whether the timeout is never timeout in ms. |
| 1067 | + * @return 0, success; otherswise, failed. | ||
| 1068 | + */ | ||
| 1068 | // TODO: FIXME: Upgrade srs-bench and change the us to ms for timeout. | 1069 | // TODO: FIXME: Upgrade srs-bench and change the us to ms for timeout. |
| 1069 | extern bool srs_hijack_io_is_never_timeout(srs_hijack_io_t ctx, int64_t tm); | 1070 | extern bool srs_hijack_io_is_never_timeout(srs_hijack_io_t ctx, int64_t tm); |
| 1070 | /** | 1071 | /** |
| 1071 | - * read fully, fill the buf exactly size bytes. | ||
| 1072 | - * @return 0, success; otherswise, failed. | ||
| 1073 | - */ | 1072 | + * read fully, fill the buf exactly size bytes. |
| 1073 | + * @return 0, success; otherswise, failed. | ||
| 1074 | + */ | ||
| 1074 | extern int srs_hijack_io_read_fully(srs_hijack_io_t ctx, void* buf, size_t size, ssize_t* nread); | 1075 | extern int srs_hijack_io_read_fully(srs_hijack_io_t ctx, void* buf, size_t size, ssize_t* nread); |
| 1075 | /** | 1076 | /** |
| 1076 | - * write bytes to socket. | ||
| 1077 | - * @return 0, success; otherswise, failed. | ||
| 1078 | - */ | 1077 | + * write bytes to socket. |
| 1078 | + * @return 0, success; otherswise, failed. | ||
| 1079 | + * @remark We assume that the write always write all data to peer, like what ST or block-socket done. | ||
| 1080 | + */ | ||
| 1079 | extern int srs_hijack_io_write(srs_hijack_io_t ctx, void* buf, size_t size, ssize_t* nwrite); | 1081 | extern int srs_hijack_io_write(srs_hijack_io_t ctx, void* buf, size_t size, ssize_t* nwrite); |
| 1080 | #endif | 1082 | #endif |
| 1081 | 1083 |
-
请 注册 或 登录 后发表评论