static int send_packet(struct rtmp_stream *stream, struct encoder_packet *packet, bool is_header, size_t idx) { uint8_t *data; size_t size; int recv_size = 0; int ret = 0; #ifdef _WIN32 ret = ioctlsocket(stream->rtmp.m_sb.sb_socket, FIONREAD, (u_long*)&recv_size); #else ret = ioctl(stream->rtmp.m_sb.sb_socket, FIONREAD, &recv_size); #endif if (ret >= 0 && recv_size > 0) { if (!discard_recv_data(stream, (size_t)recv_size)) return -1; } flv_packet_mux(packet, &data, &size, is_header); #ifdef TEST_FRAMEDROPS os_sleep_ms(rand() % 40); #endif ret = RTMP_Write(&stream->rtmp, (char*)data, (int)size, (int)idx); bfree(data); obs_free_encoder_packet(packet); stream->total_bytes_sent += size; return ret; }
static int write_packet(struct flv_output *stream, struct encoder_packet *packet, bool is_header) { uint8_t *data; size_t size; int ret = 0; stream->last_packet_ts = get_ms_time(packet, packet->dts); flv_packet_mux(packet, &data, &size, is_header); fwrite(data, 1, size, stream->file); bfree(data); obs_free_encoder_packet(packet); return ret; }
static int send_packet(struct rtmp_stream *stream, struct encoder_packet *packet, bool is_header) { uint8_t *data; size_t size; int ret = 0; flv_packet_mux(packet, &data, &size, is_header); #ifdef FILE_TEST fwrite(data, 1, size, stream->test); #else ret = RTMP_Write(&stream->rtmp, (char*)data, (int)size); #endif bfree(data); obs_free_encoder_packet(packet); return ret; }
static int send_packet(struct rtmp_stream *stream, struct encoder_packet *packet, bool is_header, size_t idx) { uint8_t *data; size_t size; int ret = 0; flv_packet_mux(packet, &data, &size, is_header); #ifdef TEST_FRAMEDROPS os_sleep_ms(rand() % 40); #endif ret = RTMP_Write(&stream->rtmp, (char*)data, (int)size, (int)idx); bfree(data); obs_free_encoder_packet(packet); stream->total_bytes_sent += size; return ret; }
static int send_packet(struct rtmp_stream *stream, struct encoder_packet *packet, bool is_header, size_t idx) { uint8_t *data; size_t size; int recv_size = 0; int ret = 0; if (!stream->new_socket_loop) { #ifdef _WIN32 ret = ioctlsocket(stream->rtmp.m_sb.sb_socket, FIONREAD, (u_long*)&recv_size); #else ret = ioctl(stream->rtmp.m_sb.sb_socket, FIONREAD, &recv_size); #endif if (ret >= 0 && recv_size > 0) { if (!discard_recv_data(stream, (size_t)recv_size)) return -1; } } flv_packet_mux(packet, &data, &size, is_header); #ifdef TEST_FRAMEDROPS droptest_cap_data_rate(stream, size); #endif ret = RTMP_Write(&stream->rtmp, (char*)data, (int)size, (int)idx); bfree(data); if (is_header) bfree(packet->data); else obs_encoder_packet_release(packet); stream->total_bytes_sent += size; return ret; }