当前位置: 首页>>代码示例>>C++>>正文


C++ SrsCommonMessage::set_packet方法代码示例

本文整理汇总了C++中SrsCommonMessage::set_packet方法的典型用法代码示例。如果您正苦于以下问题:C++ SrsCommonMessage::set_packet方法的具体用法?C++ SrsCommonMessage::set_packet怎么用?C++ SrsCommonMessage::set_packet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SrsCommonMessage的用法示例。


在下文中一共展示了SrsCommonMessage::set_packet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: fmle_unpublish

int SrsRtmp::fmle_unpublish(int stream_id, double unpublish_tid)
{
	int ret = ERROR_SUCCESS;
	
	// publish response onFCUnpublish(NetStream.unpublish.Success)
	if (true) {
		SrsCommonMessage* msg = new SrsCommonMessage();
		SrsOnStatusCallPacket* pkt = new SrsOnStatusCallPacket();
		
		pkt->command_name = RTMP_AMF0_COMMAND_ON_FC_UNPUBLISH;
		pkt->data->set(StatusCode, new SrsAmf0String(StatusCodeUnpublishSuccess));
		pkt->data->set(StatusDescription, new SrsAmf0String("Stop publishing stream."));
		
		msg->set_packet(pkt, stream_id);
		
		if ((ret = protocol->send_message(msg)) != ERROR_SUCCESS) {
			srs_error("send onFCUnpublish(NetStream.unpublish.Success) message failed. ret=%d", ret);
			return ret;
		}
		srs_info("send onFCUnpublish(NetStream.unpublish.Success) message success.");
	}
	// FCUnpublish response
	if (true) {
		SrsCommonMessage* msg = new SrsCommonMessage();
		SrsFMLEStartResPacket* pkt = new SrsFMLEStartResPacket(unpublish_tid);
		
		msg->set_packet(pkt, stream_id);
		
		if ((ret = protocol->send_message(msg)) != ERROR_SUCCESS) {
			srs_error("send FCUnpublish response message failed. ret=%d", ret);
			return ret;
		}
		srs_info("send FCUnpublish response message success.");
	}
	// publish response onStatus(NetStream.Unpublish.Success)
	if (true) {
		SrsCommonMessage* msg = new SrsCommonMessage();
		SrsOnStatusCallPacket* pkt = new SrsOnStatusCallPacket();
		
		pkt->data->set(StatusLevel, new SrsAmf0String(StatusLevelStatus));
		pkt->data->set(StatusCode, new SrsAmf0String(StatusCodeUnpublishSuccess));
		pkt->data->set(StatusDescription, new SrsAmf0String("Stream is now unpublished"));
		pkt->data->set(StatusClientId, new SrsAmf0String(RTMP_SIG_CLIENT_ID));
		
		msg->set_packet(pkt, stream_id);
		
		if ((ret = protocol->send_message(msg)) != ERROR_SUCCESS) {
			srs_error("send onStatus(NetStream.Unpublish.Success) message failed. ret=%d", ret);
			return ret;
		}
		srs_info("send onStatus(NetStream.Unpublish.Success) message success.");
	}
	
	srs_info("FMLE unpublish success.");
	
	return ret;
}
开发者ID:abao1900,项目名称:simple-rtmp-server,代码行数:57,代码来源:srs_core_rtmp.cpp

示例2: play

int SrsRtmpClient::play(string stream, int stream_id)
{
    int ret = ERROR_SUCCESS;

    // Play(stream)
    if (true) {
        SrsCommonMessage* msg = new SrsCommonMessage();
        SrsPlayPacket* pkt = new SrsPlayPacket();
    
        pkt->stream_name = stream;
        msg->set_packet(pkt, stream_id);
        
        if ((ret = protocol->send_message(msg)) != ERROR_SUCCESS) {
            srs_error("send play stream failed. "
                "stream=%s, stream_id=%d, ret=%d", 
                stream.c_str(), stream_id, ret);
            return ret;
        }
    }
    
    // SetBufferLength(1000ms)
    int buffer_length_ms = 1000;
    if (true) {
        SrsCommonMessage* msg = new SrsCommonMessage();
        SrsUserControlPacket* pkt = new SrsUserControlPacket();
    
        pkt->event_type = SrcPCUCSetBufferLength;
        pkt->event_data = stream_id;
        pkt->extra_data = buffer_length_ms;
        msg->set_packet(pkt, 0);
        
        if ((ret = protocol->send_message(msg)) != ERROR_SUCCESS) {
            srs_error("send set buffer length failed. "
                "stream=%s, stream_id=%d, bufferLength=%d, ret=%d", 
                stream.c_str(), stream_id, buffer_length_ms, ret);
            return ret;
        }
    }
    
    // SetChunkSize
    if (true) {
        SrsCommonMessage* msg = new SrsCommonMessage();
        SrsSetChunkSizePacket* pkt = new SrsSetChunkSizePacket();
    
        pkt->chunk_size = SRS_CONF_DEFAULT_CHUNK_SIZE;
        msg->set_packet(pkt, 0);
        
        if ((ret = protocol->send_message(msg)) != ERROR_SUCCESS) {
            srs_error("send set chunk size failed. "
                "stream=%s, chunk_size=%d, ret=%d", 
                stream.c_str(), SRS_CONF_DEFAULT_CHUNK_SIZE, ret);
            return ret;
        }
    }
    
    return ret;
}
开发者ID:byteman,项目名称:simple-rtmp-server,代码行数:57,代码来源:srs_protocol_rtmp.cpp

示例3: connect_app

int SrsRtmpClient::connect_app(string app, string tc_url)
{
	int ret = ERROR_SUCCESS;
	
	// Connect(vhost, app)
	if (true) {
		SrsCommonMessage* msg = new SrsCommonMessage();
		SrsConnectAppPacket* pkt = new SrsConnectAppPacket();
		msg->set_packet(pkt, 0);
		
		pkt->command_object = new SrsAmf0Object();
		pkt->command_object->set("app", new SrsAmf0String(app.c_str()));
		pkt->command_object->set("swfUrl", new SrsAmf0String());
		pkt->command_object->set("tcUrl", new SrsAmf0String(tc_url.c_str()));
		pkt->command_object->set("fpad", new SrsAmf0Boolean(false));
		pkt->command_object->set("capabilities", new SrsAmf0Number(239));
		pkt->command_object->set("audioCodecs", new SrsAmf0Number(3575));
		pkt->command_object->set("videoCodecs", new SrsAmf0Number(252));
		pkt->command_object->set("videoFunction", new SrsAmf0Number(1));
		pkt->command_object->set("pageUrl", new SrsAmf0String());
		pkt->command_object->set("objectEncoding", new SrsAmf0Number(0));
		
		if ((ret = protocol->send_message(msg)) != ERROR_SUCCESS) {
			return ret;
		}
	}
	
	// Set Window Acknowledgement size(2500000)
	if (true) {
		SrsCommonMessage* msg = new SrsCommonMessage();
		SrsSetWindowAckSizePacket* pkt = new SrsSetWindowAckSizePacket();
	
		pkt->ackowledgement_window_size = 2500000;
		msg->set_packet(pkt, 0);
		
		if ((ret = protocol->send_message(msg)) != ERROR_SUCCESS) {
			return ret;
		}
	}
	
	// expect connect _result
	SrsCommonMessage* msg = NULL;
	SrsConnectAppResPacket* pkt = NULL;
	if ((ret = srs_rtmp_expect_message<SrsConnectAppResPacket>(protocol, &msg, &pkt)) != ERROR_SUCCESS) {
		srs_error("expect connect app response message failed. ret=%d", ret);
		return ret;
	}
	SrsAutoFree(SrsCommonMessage, msg, false);
	srs_info("get connect app response message");
	
    return ret;
}
开发者ID:abao1900,项目名称:simple-rtmp-server,代码行数:52,代码来源:srs_core_rtmp.cpp

示例4: create_stream

int SrsRtmpClient::create_stream(int& stream_id)
{
	int ret = ERROR_SUCCESS;
	
	// CreateStream
	if (true) {
		SrsCommonMessage* msg = new SrsCommonMessage();
		SrsCreateStreamPacket* pkt = new SrsCreateStreamPacket();
	
		msg->set_packet(pkt, 0);
		
		if ((ret = protocol->send_message(msg)) != ERROR_SUCCESS) {
			return ret;
		}
	}

	// CreateStream _result.
	if (true) {
		SrsCommonMessage* msg = NULL;
		SrsCreateStreamResPacket* pkt = NULL;
		if ((ret = srs_rtmp_expect_message<SrsCreateStreamResPacket>(protocol, &msg, &pkt)) != ERROR_SUCCESS) {
			srs_error("expect create stream response message failed. ret=%d", ret);
			return ret;
		}
		SrsAutoFree(SrsCommonMessage, msg, false);
		srs_info("get create stream response message");

		stream_id = (int)pkt->stream_id;
	}
	
	return ret;
}
开发者ID:abao1900,项目名称:simple-rtmp-server,代码行数:32,代码来源:srs_core_rtmp.cpp

示例5: start_flash_publish

int SrsRtmp::start_flash_publish(int stream_id)
{
	int ret = ERROR_SUCCESS;
	
	// publish response onStatus(NetStream.Publish.Start)
	if (true) {
		SrsCommonMessage* msg = new SrsCommonMessage();
		SrsOnStatusCallPacket* pkt = new SrsOnStatusCallPacket();
		
		pkt->data->set(StatusLevel, new SrsAmf0String(StatusLevelStatus));
		pkt->data->set(StatusCode, new SrsAmf0String(StatusCodePublishStart));
		pkt->data->set(StatusDescription, new SrsAmf0String("Started publishing stream."));
		pkt->data->set(StatusClientId, new SrsAmf0String(RTMP_SIG_CLIENT_ID));
		
		msg->set_packet(pkt, stream_id);
		
		if ((ret = protocol->send_message(msg)) != ERROR_SUCCESS) {
			srs_error("send onStatus(NetStream.Publish.Start) message failed. ret=%d", ret);
			return ret;
		}
		srs_info("send onStatus(NetStream.Publish.Start) message success.");
	}
	
	srs_info("flash publish success.");
	
	return ret;
}
开发者ID:abao1900,项目名称:simple-rtmp-server,代码行数:27,代码来源:srs_core_rtmp.cpp

示例6: identify_create_stream_client

int SrsRtmp::identify_create_stream_client(SrsCreateStreamPacket* req, int stream_id, SrsClientType& type, string& stream_name)
{
	int ret = ERROR_SUCCESS;
	
	if (true) {
		SrsCommonMessage* msg = new SrsCommonMessage();
		SrsCreateStreamResPacket* pkt = new SrsCreateStreamResPacket(req->transaction_id, stream_id);
		
		msg->set_packet(pkt, 0);
		
		if ((ret = protocol->send_message(msg)) != ERROR_SUCCESS) {
			srs_error("send createStream response message failed. ret=%d", ret);
			return ret;
		}
		srs_info("send createStream response message success.");
	}
	
	while (true) {
		SrsCommonMessage* msg = NULL;
		if ((ret = protocol->recv_message(&msg)) != ERROR_SUCCESS) {
			srs_error("recv identify client message failed. ret=%d", ret);
			return ret;
		}

		SrsAutoFree(SrsCommonMessage, msg, false);

		if (!msg->header.is_amf0_command() && !msg->header.is_amf3_command()) {
			srs_trace("identify ignore messages except "
				"AMF0/AMF3 command message. type=%#x", msg->header.message_type);
			continue;
		}
		
		if ((ret = msg->decode_packet(protocol)) != ERROR_SUCCESS) {
			srs_error("identify decode message failed. ret=%d", ret);
			return ret;
		}
		
		SrsPacket* pkt = msg->get_packet();
		if (dynamic_cast<SrsPlayPacket*>(pkt)) {
			SrsPlayPacket* play = dynamic_cast<SrsPlayPacket*>(pkt);
			type = SrsClientPlay;
			stream_name = play->stream_name;
			srs_trace("identity client type=play, stream_name=%s", stream_name.c_str());
			return ret;
		}
		if (dynamic_cast<SrsPublishPacket*>(pkt)) {
			srs_info("identify client by publish, falsh publish.");
			return identify_flash_publish_client(
				dynamic_cast<SrsPublishPacket*>(pkt), type, stream_name);
		}
		
		srs_trace("ignore AMF0/AMF3 command message.");
	}
	
	return ret;
}
开发者ID:abao1900,项目名称:simple-rtmp-server,代码行数:56,代码来源:srs_core_rtmp.cpp

示例7: publish

int SrsRtmpClient::publish(string stream, int stream_id)
{
    int ret = ERROR_SUCCESS;
    
    // SetChunkSize
    if (true) {
        SrsCommonMessage* msg = new SrsCommonMessage();
        SrsSetChunkSizePacket* pkt = new SrsSetChunkSizePacket();
    
        pkt->chunk_size = SRS_CONF_DEFAULT_CHUNK_SIZE;
        msg->set_packet(pkt, 0);
        
        if ((ret = protocol->send_message(msg)) != ERROR_SUCCESS) {
            srs_error("send set chunk size failed. "
                "stream=%s, chunk_size=%d, ret=%d", 
                stream.c_str(), SRS_CONF_DEFAULT_CHUNK_SIZE, ret);
            return ret;
        }
    }

    // publish(stream)
    if (true) {
        SrsCommonMessage* msg = new SrsCommonMessage();
        SrsPublishPacket* pkt = new SrsPublishPacket();
    
        pkt->stream_name = stream;
        msg->set_packet(pkt, stream_id);
        
        if ((ret = protocol->send_message(msg)) != ERROR_SUCCESS) {
            srs_error("send publish message failed. "
                "stream=%s, stream_id=%d, ret=%d", 
                stream.c_str(), stream_id, ret);
            return ret;
        }
    }
    
    return ret;
}
开发者ID:byteman,项目名称:simple-rtmp-server,代码行数:38,代码来源:srs_protocol_rtmp.cpp

示例8: on_bw_done

int SrsRtmp::on_bw_done()
{
	int ret = ERROR_SUCCESS;
	
	SrsCommonMessage* msg = new SrsCommonMessage();
	SrsOnBWDonePacket* pkt = new SrsOnBWDonePacket();
	
	msg->set_packet(pkt, 0);
	
	if ((ret = protocol->send_message(msg)) != ERROR_SUCCESS) {
		srs_error("send onBWDone message failed. ret=%d", ret);
		return ret;
	}
	srs_info("send onBWDone message success.");
	
	return ret;
}
开发者ID:abao1900,项目名称:simple-rtmp-server,代码行数:17,代码来源:srs_core_rtmp.cpp

示例9: set_chunk_size

int SrsRtmp::set_chunk_size(int chunk_size)
{
	int ret = ERROR_SUCCESS;
	
	SrsCommonMessage* msg = new SrsCommonMessage();
	SrsSetChunkSizePacket* pkt = new SrsSetChunkSizePacket();
	
	pkt->chunk_size = chunk_size;
	msg->set_packet(pkt, 0);
	
	if ((ret = protocol->send_message(msg)) != ERROR_SUCCESS) {
		srs_error("send set chunk size message failed. ret=%d", ret);
		return ret;
	}
	srs_info("send set chunk size message success. chunk_size=%d", chunk_size);
	
	return ret;
}
开发者ID:abao1900,项目名称:simple-rtmp-server,代码行数:18,代码来源:srs_core_rtmp.cpp

示例10: set_window_ack_size

int SrsRtmp::set_window_ack_size(int ack_size)
{
	int ret = ERROR_SUCCESS;
	
	SrsCommonMessage* msg = new SrsCommonMessage();
	SrsSetWindowAckSizePacket* pkt = new SrsSetWindowAckSizePacket();
	
	pkt->ackowledgement_window_size = ack_size;
	msg->set_packet(pkt, 0);
	
	if ((ret = protocol->send_message(msg)) != ERROR_SUCCESS) {
		srs_error("send ack size message failed. ret=%d", ret);
		return ret;
	}
	srs_info("send ack size message success. ack_size=%d", ack_size);
	
	return ret;
}
开发者ID:abao1900,项目名称:simple-rtmp-server,代码行数:18,代码来源:srs_core_rtmp.cpp

示例11: response_connect_app

int SrsRtmpServer::response_connect_app(SrsRequest *req, const char* server_ip)
{
    int ret = ERROR_SUCCESS;
    
    SrsCommonMessage* msg = new SrsCommonMessage();
    SrsConnectAppResPacket* pkt = new SrsConnectAppResPacket();
    
    pkt->props->set("fmsVer", SrsAmf0Any::str("FMS/"RTMP_SIG_FMS_VER));
    pkt->props->set("capabilities", SrsAmf0Any::number(127));
    pkt->props->set("mode", SrsAmf0Any::number(1));
    
    pkt->info->set(StatusLevel, SrsAmf0Any::str(StatusLevelStatus));
    pkt->info->set(StatusCode, SrsAmf0Any::str(StatusCodeConnectSuccess));
    pkt->info->set(StatusDescription, SrsAmf0Any::str("Connection succeeded"));
    pkt->info->set("objectEncoding", SrsAmf0Any::number(req->objectEncoding));
    SrsAmf0EcmaArray* data = SrsAmf0Any::ecma_array();
    pkt->info->set("data", data);
    
    data->set("version", SrsAmf0Any::str(RTMP_SIG_FMS_VER));
    data->set("srs_sig", SrsAmf0Any::str(RTMP_SIG_SRS_KEY));
    data->set("srs_server", SrsAmf0Any::str(RTMP_SIG_SRS_KEY" "RTMP_SIG_SRS_VERSION" ("RTMP_SIG_SRS_URL_SHORT")"));
    data->set("srs_license", SrsAmf0Any::str(RTMP_SIG_SRS_LICENSE));
    data->set("srs_role", SrsAmf0Any::str(RTMP_SIG_SRS_ROLE));
    data->set("srs_url", SrsAmf0Any::str(RTMP_SIG_SRS_URL));
    data->set("srs_version", SrsAmf0Any::str(RTMP_SIG_SRS_VERSION));
    data->set("srs_site", SrsAmf0Any::str(RTMP_SIG_SRS_WEB));
    data->set("srs_email", SrsAmf0Any::str(RTMP_SIG_SRS_EMAIL));
    data->set("srs_copyright", SrsAmf0Any::str(RTMP_SIG_SRS_COPYRIGHT));
    data->set("srs_primary_authors", SrsAmf0Any::str(RTMP_SIG_SRS_PRIMARY_AUTHROS));
    
    if (server_ip) {
        data->set("srs_server_ip", SrsAmf0Any::str(server_ip));
    }
    
    msg->set_packet(pkt, 0);
    
    if ((ret = protocol->send_message(msg)) != ERROR_SUCCESS) {
        srs_error("send connect app response message failed. ret=%d", ret);
        return ret;
    }
    srs_info("send connect app response message success.");
    
    return ret;
}
开发者ID:byteman,项目名称:simple-rtmp-server,代码行数:44,代码来源:srs_protocol_rtmp.cpp

示例12: set_peer_bandwidth

int SrsRtmp::set_peer_bandwidth(int bandwidth, int type)
{
	int ret = ERROR_SUCCESS;
	
	SrsCommonMessage* msg = new SrsCommonMessage();
	SrsSetPeerBandwidthPacket* pkt = new SrsSetPeerBandwidthPacket();
	
	pkt->bandwidth = bandwidth;
	pkt->type = type;
	msg->set_packet(pkt, 0);
	
	if ((ret = protocol->send_message(msg)) != ERROR_SUCCESS) {
		srs_error("send set bandwidth message failed. ret=%d", ret);
		return ret;
	}
	srs_info("send set bandwidth message "
		"success. bandwidth=%d, type=%d", bandwidth, type);
	
	return ret;
}
开发者ID:abao1900,项目名称:simple-rtmp-server,代码行数:20,代码来源:srs_core_rtmp.cpp

示例13: publish

int SrsRtmpClient::publish(string stream, int stream_id)
{
	int ret = ERROR_SUCCESS;

	// publish(stream)
	if (true) {
		SrsCommonMessage* msg = new SrsCommonMessage();
		SrsPublishPacket* pkt = new SrsPublishPacket();
	
		pkt->stream_name = stream;
		msg->set_packet(pkt, stream_id);
		
		if ((ret = protocol->send_message(msg)) != ERROR_SUCCESS) {
			srs_error("send publish message failed. "
				"stream=%s, stream_id=%d, ret=%d", 
				stream.c_str(), stream_id, ret);
			return ret;
		}
	}
	
	return ret;
}
开发者ID:abao1900,项目名称:simple-rtmp-server,代码行数:22,代码来源:srs_core_rtmp.cpp

示例14: response_connect_app

int SrsRtmp::response_connect_app(SrsRequest* req)
{
	int ret = ERROR_SUCCESS;
	
	SrsCommonMessage* msg = new SrsCommonMessage();
	SrsConnectAppResPacket* pkt = new SrsConnectAppResPacket();
	
	pkt->props->set("fmsVer", new SrsAmf0String("FMS/"RTMP_SIG_FMS_VER));
	pkt->props->set("capabilities", new SrsAmf0Number(127));
	pkt->props->set("mode", new SrsAmf0Number(1));
	
	pkt->info->set(StatusLevel, new SrsAmf0String(StatusLevelStatus));
	pkt->info->set(StatusCode, new SrsAmf0String(StatusCodeConnectSuccess));
	pkt->info->set(StatusDescription, new SrsAmf0String("Connection succeeded"));
	pkt->info->set("objectEncoding", new SrsAmf0Number(req->objectEncoding));
	SrsASrsAmf0EcmaArray* data = new SrsASrsAmf0EcmaArray();
	pkt->info->set("data", data);
	
	data->set("srs_version", new SrsAmf0String(RTMP_SIG_FMS_VER));
	data->set("srs_server", new SrsAmf0String(RTMP_SIG_SRS_NAME));
	data->set("srs_license", new SrsAmf0String(RTMP_SIG_SRS_LICENSE));
	data->set("srs_role", new SrsAmf0String(RTMP_SIG_SRS_ROLE));
	data->set("srs_url", new SrsAmf0String(RTMP_SIG_SRS_URL));
	data->set("srs_version", new SrsAmf0String(RTMP_SIG_SRS_VERSION));
	data->set("srs_site", new SrsAmf0String(RTMP_SIG_SRS_WEB));
	data->set("srs_email", new SrsAmf0String(RTMP_SIG_SRS_EMAIL));
	data->set("srs_copyright", new SrsAmf0String(RTMP_SIG_SRS_COPYRIGHT));
	
	msg->set_packet(pkt, 0);
	
	if ((ret = protocol->send_message(msg)) != ERROR_SUCCESS) {
		srs_error("send connect app response message failed. ret=%d", ret);
		return ret;
	}
	srs_info("send connect app response message success.");
	
	return ret;
}
开发者ID:AsamQi,项目名称:simple-rtmp-server,代码行数:38,代码来源:srs_core_rtmp.cpp

示例15: identify_fmle_publish_client

int SrsRtmp::identify_fmle_publish_client(SrsFMLEStartPacket* req, SrsClientType& type, string& stream_name)
{
	int ret = ERROR_SUCCESS;
	
	type = SrsClientFMLEPublish;
	stream_name = req->stream_name;
	
	// releaseStream response
	if (true) {
		SrsCommonMessage* msg = new SrsCommonMessage();
		SrsFMLEStartResPacket* pkt = new SrsFMLEStartResPacket(req->transaction_id);
		
		msg->set_packet(pkt, 0);
		
		if ((ret = protocol->send_message(msg)) != ERROR_SUCCESS) {
			srs_error("send releaseStream response message failed. ret=%d", ret);
			return ret;
		}
		srs_info("send releaseStream response message success.");
	}
	
	return ret;
}
开发者ID:abao1900,项目名称:simple-rtmp-server,代码行数:23,代码来源:srs_core_rtmp.cpp


注:本文中的SrsCommonMessage::set_packet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。