2010-05-13 05:07:20 +08:00
|
|
|
/***************************************************************************
|
|
|
|
* _ _ ____ _
|
|
|
|
* Project ___| | | | _ \| |
|
|
|
|
* / __| | | | |_) | |
|
|
|
|
* | (__| |_| | _ <| |___
|
|
|
|
* \___|\___/|_| \_\_____|
|
|
|
|
*
|
2021-01-09 00:58:15 +08:00
|
|
|
* Copyright (C) 2012 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
|
2010-05-13 05:07:20 +08:00
|
|
|
* Copyright (C) 2010, Howard Chu, <hyc@highlandsun.com>
|
|
|
|
*
|
|
|
|
* This software is licensed as described in the file COPYING, which
|
|
|
|
* you should have received as part of this distribution. The terms
|
2020-11-04 21:02:01 +08:00
|
|
|
* are also available at https://curl.se/docs/copyright.html.
|
2010-05-13 05:07:20 +08:00
|
|
|
*
|
|
|
|
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
|
|
|
* copies of the Software, and permit persons to whom the Software is
|
|
|
|
* furnished to do so, under the terms of the COPYING file.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
***************************************************************************/
|
|
|
|
|
2013-01-07 02:06:49 +08:00
|
|
|
#include "curl_setup.h"
|
2010-05-13 05:07:20 +08:00
|
|
|
|
|
|
|
#ifdef USE_LIBRTMP
|
|
|
|
|
2017-04-30 01:17:51 +08:00
|
|
|
#include "curl_rtmp.h"
|
2013-01-04 09:50:28 +08:00
|
|
|
#include "urldata.h"
|
|
|
|
#include "nonblock.h" /* for curlx_nonblock */
|
|
|
|
#include "progress.h" /* for Curl_pgrsSetUploadSize */
|
|
|
|
#include "transfer.h"
|
|
|
|
#include "warnless.h"
|
2010-05-13 05:07:20 +08:00
|
|
|
#include <curl/curl.h>
|
|
|
|
#include <librtmp/rtmp.h>
|
2010-06-02 20:13:02 +08:00
|
|
|
#include "curl_memory.h"
|
|
|
|
/* The last #include file should be: */
|
2013-01-04 09:50:28 +08:00
|
|
|
#include "memdebug.h"
|
2010-06-02 20:13:02 +08:00
|
|
|
|
rtmp: fix for compiling with lwIP
Compiling on _WIN32 and with USE_LWIPSOCK, causes this error:
curl_rtmp.c(223,3): error: use of undeclared identifier 'setsockopt'
setsockopt(r->m_sb.sb_socket, SOL_SOCKET, SO_RCVTIMEO,
^
curl_rtmp.c(41,32): note: expanded from macro 'setsockopt'
#define setsockopt(a,b,c,d,e) (setsockopt)(a,b,c,(const char *)d,(int)e)
^
Closes #3155
2018-10-22 16:33:44 +08:00
|
|
|
#if defined(WIN32) && !defined(USE_LWIPSOCK)
|
2010-05-13 05:07:20 +08:00
|
|
|
#define setsockopt(a,b,c,d,e) (setsockopt)(a,b,c,(const char *)d,(int)e)
|
|
|
|
#define SET_RCVTIMEO(tv,s) int tv = s*1000
|
rtmp: fix for compiling with lwIP
Compiling on _WIN32 and with USE_LWIPSOCK, causes this error:
curl_rtmp.c(223,3): error: use of undeclared identifier 'setsockopt'
setsockopt(r->m_sb.sb_socket, SOL_SOCKET, SO_RCVTIMEO,
^
curl_rtmp.c(41,32): note: expanded from macro 'setsockopt'
#define setsockopt(a,b,c,d,e) (setsockopt)(a,b,c,(const char *)d,(int)e)
^
Closes #3155
2018-10-22 16:33:44 +08:00
|
|
|
#elif defined(LWIP_SO_SNDRCVTIMEO_NONSTANDARD)
|
|
|
|
#define SET_RCVTIMEO(tv,s) int tv = s*1000
|
2010-05-13 05:07:20 +08:00
|
|
|
#else
|
|
|
|
#define SET_RCVTIMEO(tv,s) struct timeval tv = {s,0}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define DEF_BUFTIME (2*60*60*1000) /* 2 hours */
|
|
|
|
|
2021-01-09 00:58:15 +08:00
|
|
|
static CURLcode rtmp_setup_connection(struct Curl_easy *data,
|
|
|
|
struct connectdata *conn);
|
|
|
|
static CURLcode rtmp_do(struct Curl_easy *data, bool *done);
|
|
|
|
static CURLcode rtmp_done(struct Curl_easy *data, CURLcode, bool premature);
|
|
|
|
static CURLcode rtmp_connect(struct Curl_easy *data, bool *done);
|
|
|
|
static CURLcode rtmp_disconnect(struct Curl_easy *data,
|
|
|
|
struct connectdata *conn, bool dead);
|
2010-05-13 05:07:20 +08:00
|
|
|
|
|
|
|
static Curl_recv rtmp_recv;
|
|
|
|
static Curl_send rtmp_send;
|
|
|
|
|
|
|
|
/*
|
2016-02-03 12:09:25 +08:00
|
|
|
* RTMP protocol handler.h, based on https://rtmpdump.mplayerhq.hu
|
2010-05-13 05:07:20 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
const struct Curl_handler Curl_handler_rtmp = {
|
|
|
|
"RTMP", /* scheme */
|
2014-12-25 01:12:13 +08:00
|
|
|
rtmp_setup_connection, /* setup_connection */
|
2010-05-13 05:07:20 +08:00
|
|
|
rtmp_do, /* do_it */
|
|
|
|
rtmp_done, /* done */
|
|
|
|
ZERO_NULL, /* do_more */
|
|
|
|
rtmp_connect, /* connect_it */
|
|
|
|
ZERO_NULL, /* connecting */
|
|
|
|
ZERO_NULL, /* doing */
|
|
|
|
ZERO_NULL, /* proto_getsock */
|
|
|
|
ZERO_NULL, /* doing_getsock */
|
2011-10-22 05:36:54 +08:00
|
|
|
ZERO_NULL, /* domore_getsock */
|
2010-05-13 05:07:20 +08:00
|
|
|
ZERO_NULL, /* perform_getsock */
|
|
|
|
rtmp_disconnect, /* disconnect */
|
2011-05-05 22:27:03 +08:00
|
|
|
ZERO_NULL, /* readwrite */
|
2017-05-31 19:09:56 +08:00
|
|
|
ZERO_NULL, /* connection_check */
|
2021-05-17 14:54:00 +08:00
|
|
|
ZERO_NULL, /* attach connection */
|
2010-05-13 05:07:20 +08:00
|
|
|
PORT_RTMP, /* defport */
|
2011-03-15 05:52:14 +08:00
|
|
|
CURLPROTO_RTMP, /* protocol */
|
2020-09-21 19:45:24 +08:00
|
|
|
CURLPROTO_RTMP, /* family */
|
2011-03-15 05:22:22 +08:00
|
|
|
PROTOPT_NONE /* flags*/
|
2010-05-13 05:07:20 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
const struct Curl_handler Curl_handler_rtmpt = {
|
|
|
|
"RTMPT", /* scheme */
|
2014-12-25 01:12:13 +08:00
|
|
|
rtmp_setup_connection, /* setup_connection */
|
2010-05-13 05:07:20 +08:00
|
|
|
rtmp_do, /* do_it */
|
|
|
|
rtmp_done, /* done */
|
|
|
|
ZERO_NULL, /* do_more */
|
|
|
|
rtmp_connect, /* connect_it */
|
|
|
|
ZERO_NULL, /* connecting */
|
|
|
|
ZERO_NULL, /* doing */
|
|
|
|
ZERO_NULL, /* proto_getsock */
|
|
|
|
ZERO_NULL, /* doing_getsock */
|
2011-10-22 05:36:54 +08:00
|
|
|
ZERO_NULL, /* domore_getsock */
|
2010-05-13 05:07:20 +08:00
|
|
|
ZERO_NULL, /* perform_getsock */
|
|
|
|
rtmp_disconnect, /* disconnect */
|
2011-05-05 22:27:03 +08:00
|
|
|
ZERO_NULL, /* readwrite */
|
2017-05-31 19:09:56 +08:00
|
|
|
ZERO_NULL, /* connection_check */
|
2021-05-17 14:54:00 +08:00
|
|
|
ZERO_NULL, /* attach connection */
|
2010-05-13 05:07:20 +08:00
|
|
|
PORT_RTMPT, /* defport */
|
2011-03-15 05:52:14 +08:00
|
|
|
CURLPROTO_RTMPT, /* protocol */
|
2020-09-21 19:45:24 +08:00
|
|
|
CURLPROTO_RTMPT, /* family */
|
2011-03-15 05:22:22 +08:00
|
|
|
PROTOPT_NONE /* flags*/
|
2010-05-13 05:07:20 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
const struct Curl_handler Curl_handler_rtmpe = {
|
|
|
|
"RTMPE", /* scheme */
|
2014-12-25 01:12:13 +08:00
|
|
|
rtmp_setup_connection, /* setup_connection */
|
2010-05-13 05:07:20 +08:00
|
|
|
rtmp_do, /* do_it */
|
|
|
|
rtmp_done, /* done */
|
|
|
|
ZERO_NULL, /* do_more */
|
|
|
|
rtmp_connect, /* connect_it */
|
|
|
|
ZERO_NULL, /* connecting */
|
|
|
|
ZERO_NULL, /* doing */
|
|
|
|
ZERO_NULL, /* proto_getsock */
|
|
|
|
ZERO_NULL, /* doing_getsock */
|
2011-10-22 05:36:54 +08:00
|
|
|
ZERO_NULL, /* domore_getsock */
|
2010-05-13 05:07:20 +08:00
|
|
|
ZERO_NULL, /* perform_getsock */
|
|
|
|
rtmp_disconnect, /* disconnect */
|
2011-05-05 22:27:03 +08:00
|
|
|
ZERO_NULL, /* readwrite */
|
2017-05-31 19:09:56 +08:00
|
|
|
ZERO_NULL, /* connection_check */
|
2021-05-17 14:54:00 +08:00
|
|
|
ZERO_NULL, /* attach connection */
|
2010-05-13 05:07:20 +08:00
|
|
|
PORT_RTMP, /* defport */
|
2011-03-15 05:52:14 +08:00
|
|
|
CURLPROTO_RTMPE, /* protocol */
|
2020-09-21 19:45:24 +08:00
|
|
|
CURLPROTO_RTMPE, /* family */
|
2011-03-15 05:22:22 +08:00
|
|
|
PROTOPT_NONE /* flags*/
|
2010-05-13 05:07:20 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
const struct Curl_handler Curl_handler_rtmpte = {
|
|
|
|
"RTMPTE", /* scheme */
|
2014-12-25 01:12:13 +08:00
|
|
|
rtmp_setup_connection, /* setup_connection */
|
2010-05-13 05:07:20 +08:00
|
|
|
rtmp_do, /* do_it */
|
|
|
|
rtmp_done, /* done */
|
|
|
|
ZERO_NULL, /* do_more */
|
|
|
|
rtmp_connect, /* connect_it */
|
|
|
|
ZERO_NULL, /* connecting */
|
|
|
|
ZERO_NULL, /* doing */
|
|
|
|
ZERO_NULL, /* proto_getsock */
|
|
|
|
ZERO_NULL, /* doing_getsock */
|
2011-10-22 05:36:54 +08:00
|
|
|
ZERO_NULL, /* domore_getsock */
|
2010-05-13 05:07:20 +08:00
|
|
|
ZERO_NULL, /* perform_getsock */
|
|
|
|
rtmp_disconnect, /* disconnect */
|
2011-05-05 22:27:03 +08:00
|
|
|
ZERO_NULL, /* readwrite */
|
2017-05-31 19:09:56 +08:00
|
|
|
ZERO_NULL, /* connection_check */
|
2021-05-17 14:54:00 +08:00
|
|
|
ZERO_NULL, /* attach connection */
|
2010-05-13 05:07:20 +08:00
|
|
|
PORT_RTMPT, /* defport */
|
2011-03-15 05:52:14 +08:00
|
|
|
CURLPROTO_RTMPTE, /* protocol */
|
2020-09-21 19:45:24 +08:00
|
|
|
CURLPROTO_RTMPTE, /* family */
|
2011-03-15 05:22:22 +08:00
|
|
|
PROTOPT_NONE /* flags*/
|
2010-05-13 05:07:20 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
const struct Curl_handler Curl_handler_rtmps = {
|
|
|
|
"RTMPS", /* scheme */
|
2014-12-25 01:12:13 +08:00
|
|
|
rtmp_setup_connection, /* setup_connection */
|
2010-05-13 05:07:20 +08:00
|
|
|
rtmp_do, /* do_it */
|
|
|
|
rtmp_done, /* done */
|
|
|
|
ZERO_NULL, /* do_more */
|
|
|
|
rtmp_connect, /* connect_it */
|
|
|
|
ZERO_NULL, /* connecting */
|
|
|
|
ZERO_NULL, /* doing */
|
|
|
|
ZERO_NULL, /* proto_getsock */
|
|
|
|
ZERO_NULL, /* doing_getsock */
|
2011-10-22 05:36:54 +08:00
|
|
|
ZERO_NULL, /* domore_getsock */
|
2010-05-13 05:07:20 +08:00
|
|
|
ZERO_NULL, /* perform_getsock */
|
|
|
|
rtmp_disconnect, /* disconnect */
|
2011-05-05 22:27:03 +08:00
|
|
|
ZERO_NULL, /* readwrite */
|
2017-05-31 19:09:56 +08:00
|
|
|
ZERO_NULL, /* connection_check */
|
2021-05-17 14:54:00 +08:00
|
|
|
ZERO_NULL, /* attach connection */
|
2010-05-13 05:07:20 +08:00
|
|
|
PORT_RTMPS, /* defport */
|
2011-03-15 05:52:14 +08:00
|
|
|
CURLPROTO_RTMPS, /* protocol */
|
2020-09-21 19:45:24 +08:00
|
|
|
CURLPROTO_RTMP, /* family */
|
2011-03-15 05:22:22 +08:00
|
|
|
PROTOPT_NONE /* flags*/
|
2010-05-13 05:07:20 +08:00
|
|
|
};
|
2011-05-05 22:27:03 +08:00
|
|
|
|
2010-05-13 05:07:20 +08:00
|
|
|
const struct Curl_handler Curl_handler_rtmpts = {
|
|
|
|
"RTMPTS", /* scheme */
|
2014-12-25 01:12:13 +08:00
|
|
|
rtmp_setup_connection, /* setup_connection */
|
2010-05-13 05:07:20 +08:00
|
|
|
rtmp_do, /* do_it */
|
|
|
|
rtmp_done, /* done */
|
|
|
|
ZERO_NULL, /* do_more */
|
|
|
|
rtmp_connect, /* connect_it */
|
|
|
|
ZERO_NULL, /* connecting */
|
|
|
|
ZERO_NULL, /* doing */
|
|
|
|
ZERO_NULL, /* proto_getsock */
|
|
|
|
ZERO_NULL, /* doing_getsock */
|
2011-10-22 05:36:54 +08:00
|
|
|
ZERO_NULL, /* domore_getsock */
|
2010-05-13 05:07:20 +08:00
|
|
|
ZERO_NULL, /* perform_getsock */
|
|
|
|
rtmp_disconnect, /* disconnect */
|
2011-05-05 22:27:03 +08:00
|
|
|
ZERO_NULL, /* readwrite */
|
2017-05-31 19:09:56 +08:00
|
|
|
ZERO_NULL, /* connection_check */
|
2021-05-17 14:54:00 +08:00
|
|
|
ZERO_NULL, /* attach connection */
|
2010-05-13 05:07:20 +08:00
|
|
|
PORT_RTMPS, /* defport */
|
2011-03-15 05:52:14 +08:00
|
|
|
CURLPROTO_RTMPTS, /* protocol */
|
2020-09-21 19:45:24 +08:00
|
|
|
CURLPROTO_RTMPT, /* family */
|
2011-03-15 05:22:22 +08:00
|
|
|
PROTOPT_NONE /* flags*/
|
2010-05-13 05:07:20 +08:00
|
|
|
};
|
|
|
|
|
2021-01-09 00:58:15 +08:00
|
|
|
static CURLcode rtmp_setup_connection(struct Curl_easy *data,
|
|
|
|
struct connectdata *conn)
|
2010-05-13 05:07:20 +08:00
|
|
|
{
|
|
|
|
RTMP *r = RTMP_Alloc();
|
2011-04-20 21:17:42 +08:00
|
|
|
if(!r)
|
2010-05-13 05:07:20 +08:00
|
|
|
return CURLE_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
RTMP_Init(r);
|
|
|
|
RTMP_SetBufferMS(r, DEF_BUFTIME);
|
2021-03-26 21:25:45 +08:00
|
|
|
if(!RTMP_SetupURL(r, data->state.url)) {
|
2010-05-13 05:07:20 +08:00
|
|
|
RTMP_Free(r);
|
|
|
|
return CURLE_URL_MALFORMAT;
|
|
|
|
}
|
2019-09-03 19:31:44 +08:00
|
|
|
conn->proto.rtmp = r;
|
2010-05-13 05:07:20 +08:00
|
|
|
return CURLE_OK;
|
|
|
|
}
|
|
|
|
|
2021-01-09 00:58:15 +08:00
|
|
|
static CURLcode rtmp_connect(struct Curl_easy *data, bool *done)
|
2010-05-13 05:07:20 +08:00
|
|
|
{
|
2021-01-09 00:58:15 +08:00
|
|
|
struct connectdata *conn = data->conn;
|
2019-09-03 19:31:44 +08:00
|
|
|
RTMP *r = conn->proto.rtmp;
|
2015-03-17 20:41:49 +08:00
|
|
|
SET_RCVTIMEO(tv, 10);
|
2010-05-13 05:07:20 +08:00
|
|
|
|
2017-07-07 17:52:48 +08:00
|
|
|
r->m_sb.sb_socket = (int)conn->sock[FIRSTSOCKET];
|
2010-05-13 05:07:20 +08:00
|
|
|
|
|
|
|
/* We have to know if it's a write before we send the
|
|
|
|
* connect request packet
|
|
|
|
*/
|
2021-01-21 07:38:52 +08:00
|
|
|
if(data->set.upload)
|
2010-05-13 05:07:20 +08:00
|
|
|
r->Link.protocol |= RTMP_FEATURE_WRITE;
|
|
|
|
|
|
|
|
/* For plain streams, use the buffer toggle trick to keep data flowing */
|
2011-04-20 21:17:42 +08:00
|
|
|
if(!(r->Link.lFlags & RTMP_LF_LIVE) &&
|
|
|
|
!(r->Link.protocol & RTMP_FEATURE_HTTP))
|
2010-05-13 05:07:20 +08:00
|
|
|
r->Link.lFlags |= RTMP_LF_BUFX;
|
|
|
|
|
2014-10-04 21:14:27 +08:00
|
|
|
(void)curlx_nonblock(r->m_sb.sb_socket, FALSE);
|
2011-04-20 21:17:42 +08:00
|
|
|
setsockopt(r->m_sb.sb_socket, SOL_SOCKET, SO_RCVTIMEO,
|
|
|
|
(char *)&tv, sizeof(tv));
|
2010-05-13 05:07:20 +08:00
|
|
|
|
2011-04-20 21:17:42 +08:00
|
|
|
if(!RTMP_Connect1(r, NULL))
|
2010-05-13 05:07:20 +08:00
|
|
|
return CURLE_FAILED_INIT;
|
|
|
|
|
|
|
|
/* Clients must send a periodic BytesReceived report to the server */
|
|
|
|
r->m_bSendCounter = true;
|
|
|
|
|
|
|
|
*done = TRUE;
|
|
|
|
conn->recv[FIRSTSOCKET] = rtmp_recv;
|
|
|
|
conn->send[FIRSTSOCKET] = rtmp_send;
|
|
|
|
return CURLE_OK;
|
|
|
|
}
|
|
|
|
|
2021-01-09 00:58:15 +08:00
|
|
|
static CURLcode rtmp_do(struct Curl_easy *data, bool *done)
|
2010-05-13 05:07:20 +08:00
|
|
|
{
|
2021-01-09 00:58:15 +08:00
|
|
|
struct connectdata *conn = data->conn;
|
2019-09-03 19:31:44 +08:00
|
|
|
RTMP *r = conn->proto.rtmp;
|
2010-05-13 05:07:20 +08:00
|
|
|
|
2011-04-20 21:17:42 +08:00
|
|
|
if(!RTMP_ConnectStream(r, 0))
|
2010-05-13 05:07:20 +08:00
|
|
|
return CURLE_FAILED_INIT;
|
|
|
|
|
2021-01-21 07:38:52 +08:00
|
|
|
if(data->set.upload) {
|
2019-02-28 18:36:26 +08:00
|
|
|
Curl_pgrsSetUploadSize(data, data->state.infilesize);
|
|
|
|
Curl_setup_transfer(data, -1, -1, FALSE, FIRSTSOCKET);
|
2011-04-20 21:17:42 +08:00
|
|
|
}
|
|
|
|
else
|
2019-02-28 18:36:26 +08:00
|
|
|
Curl_setup_transfer(data, FIRSTSOCKET, -1, FALSE, -1);
|
2010-05-13 05:07:20 +08:00
|
|
|
*done = TRUE;
|
|
|
|
return CURLE_OK;
|
|
|
|
}
|
|
|
|
|
2021-01-09 00:58:15 +08:00
|
|
|
static CURLcode rtmp_done(struct Curl_easy *data, CURLcode status,
|
2010-05-13 05:07:20 +08:00
|
|
|
bool premature)
|
|
|
|
{
|
2021-01-09 00:58:15 +08:00
|
|
|
(void)data; /* unused */
|
2010-05-25 21:43:41 +08:00
|
|
|
(void)status; /* unused */
|
|
|
|
(void)premature; /* unused */
|
|
|
|
|
2010-05-13 05:07:20 +08:00
|
|
|
return CURLE_OK;
|
|
|
|
}
|
|
|
|
|
2021-01-09 00:58:15 +08:00
|
|
|
static CURLcode rtmp_disconnect(struct Curl_easy *data,
|
|
|
|
struct connectdata *conn,
|
2010-12-06 22:33:38 +08:00
|
|
|
bool dead_connection)
|
2010-05-13 05:07:20 +08:00
|
|
|
{
|
2019-09-03 19:31:44 +08:00
|
|
|
RTMP *r = conn->proto.rtmp;
|
2021-01-09 00:58:15 +08:00
|
|
|
(void)data;
|
2010-12-06 22:33:38 +08:00
|
|
|
(void)dead_connection;
|
2011-04-20 21:17:42 +08:00
|
|
|
if(r) {
|
2019-09-03 19:31:44 +08:00
|
|
|
conn->proto.rtmp = NULL;
|
2010-05-13 05:07:20 +08:00
|
|
|
RTMP_Close(r);
|
|
|
|
RTMP_Free(r);
|
|
|
|
}
|
|
|
|
return CURLE_OK;
|
|
|
|
}
|
|
|
|
|
2021-01-09 00:58:15 +08:00
|
|
|
static ssize_t rtmp_recv(struct Curl_easy *data, int sockindex, char *buf,
|
2010-05-13 05:07:20 +08:00
|
|
|
size_t len, CURLcode *err)
|
|
|
|
{
|
2021-01-09 00:58:15 +08:00
|
|
|
struct connectdata *conn = data->conn;
|
2019-09-03 19:31:44 +08:00
|
|
|
RTMP *r = conn->proto.rtmp;
|
2010-05-13 05:07:20 +08:00
|
|
|
ssize_t nread;
|
|
|
|
|
2010-05-25 21:43:41 +08:00
|
|
|
(void)sockindex; /* unused */
|
|
|
|
|
2012-09-29 05:57:04 +08:00
|
|
|
nread = RTMP_Read(r, buf, curlx_uztosi(len));
|
2011-04-20 21:17:42 +08:00
|
|
|
if(nread < 0) {
|
|
|
|
if(r->m_read.status == RTMP_READ_COMPLETE ||
|
2021-01-09 00:58:15 +08:00
|
|
|
r->m_read.status == RTMP_READ_EOF) {
|
|
|
|
data->req.size = data->req.bytecount;
|
2010-05-13 05:07:20 +08:00
|
|
|
nread = 0;
|
2011-04-20 21:17:42 +08:00
|
|
|
}
|
|
|
|
else
|
2010-05-13 05:07:20 +08:00
|
|
|
*err = CURLE_RECV_ERROR;
|
|
|
|
}
|
|
|
|
return nread;
|
|
|
|
}
|
|
|
|
|
2021-01-09 00:58:15 +08:00
|
|
|
static ssize_t rtmp_send(struct Curl_easy *data, int sockindex,
|
2010-05-13 05:07:20 +08:00
|
|
|
const void *buf, size_t len, CURLcode *err)
|
|
|
|
{
|
2021-01-09 00:58:15 +08:00
|
|
|
struct connectdata *conn = data->conn;
|
2019-09-03 19:31:44 +08:00
|
|
|
RTMP *r = conn->proto.rtmp;
|
2010-05-13 05:07:20 +08:00
|
|
|
ssize_t num;
|
|
|
|
|
2010-05-25 21:43:41 +08:00
|
|
|
(void)sockindex; /* unused */
|
|
|
|
|
2012-09-29 05:57:04 +08:00
|
|
|
num = RTMP_Write(r, (char *)buf, curlx_uztosi(len));
|
2011-04-20 21:17:42 +08:00
|
|
|
if(num < 0)
|
2010-05-13 05:07:20 +08:00
|
|
|
*err = CURLE_SEND_ERROR;
|
2011-04-20 21:17:42 +08:00
|
|
|
|
2010-05-13 05:07:20 +08:00
|
|
|
return num;
|
|
|
|
}
|
|
|
|
#endif /* USE_LIBRTMP */
|