diff --git a/src/projects/providers/rtmp/rtmp_application.cpp b/src/projects/providers/rtmp/rtmp_application.cpp index d655ea3d3..2de815cd0 100644 --- a/src/projects/providers/rtmp/rtmp_application.cpp +++ b/src/projects/providers/rtmp/rtmp_application.cpp @@ -8,12 +8,11 @@ //============================================================================== #include "rtmp_application.h" -#include "rtmp_stream.h" -#include "rtmp_provider_private.h" -#include "base/provider/push_provider/application.h" #include "base/info/stream.h" - +#include "base/provider/push_provider/application.h" +#include "rtmp_provider_private.h" +#include "rtmp_stream.h" namespace pvd { @@ -32,24 +31,24 @@ namespace pvd bool RtmpApplication::JoinStream(const std::shared_ptr &stream) { // Check duplicated stream name - // If there is a same stream name + // If there is a same stream name auto exist_stream = GetStreamByName(stream->GetName()); - if(exist_stream != nullptr) + if (exist_stream != nullptr) { // Block - if(GetConfig().GetProviders().GetRtmpProvider().IsBlockDuplicateStreamName()) + if (GetConfig().GetProviders().GetRtmpProvider().IsBlockDuplicateStreamName()) { - logti("Reject %s/%s stream it is a stream with a duplicate name.", GetVHostAppName().CStr(), stream->GetName().CStr()); + logti("Reject %s/%s stream it is a stream with a duplicate name.", GetVHostAppName().CStr(), stream->GetName().CStr()); return false; } else { // Disconnect exist stream - logti("Remove exist %s/%s stream because the stream with the same name is connected.", GetVHostAppName().CStr(), stream->GetName().CStr()); + logti("Remove exist %s/%s stream because the stream with the same name is connected.", GetVHostAppName().CStr(), stream->GetName().CStr()); DeleteStream(exist_stream); } } return PushApplication::JoinStream(stream); } -} \ No newline at end of file +} // namespace pvd diff --git a/src/projects/providers/rtmp/rtmp_application.h b/src/projects/providers/rtmp/rtmp_application.h index 70e1ef725..749f0951b 100644 --- a/src/projects/providers/rtmp/rtmp_application.h +++ b/src/projects/providers/rtmp/rtmp_application.h @@ -13,12 +13,10 @@ #include "base/provider/push_provider/application.h" #include "base/provider/push_provider/stream.h" - namespace pvd { class RtmpApplication : public PushApplication { - public: static std::shared_ptr Create(const std::shared_ptr &provider, const info::Application &application_info); @@ -27,4 +25,4 @@ namespace pvd bool JoinStream(const std::shared_ptr &stream) override; }; -} \ No newline at end of file +} // namespace pvd diff --git a/src/projects/providers/rtmp/rtmp_stream.h b/src/projects/providers/rtmp/rtmp_stream.h index 43c704e8c..ec48ccdab 100644 --- a/src/projects/providers/rtmp/rtmp_stream.h +++ b/src/projects/providers/rtmp/rtmp_stream.h @@ -9,23 +9,22 @@ #pragma once +#include "amf0/amf_document.h" #include "base/common_types.h" #include "base/provider/push_provider/stream.h" -#include "modules/access_control/access_controller.h" - -#include "amf0/amf_document.h" +#include "chunk/rtmp_chunk_parser.h" #include "chunk/rtmp_export_chunk.h" #include "chunk/rtmp_handshake.h" -#include "chunk/rtmp_chunk_parser.h" +#include "modules/access_control/access_controller.h" #define MAX_STREAM_MESSAGE_COUNT (500) #define BASELINE_PROFILE (66) #define MAIN_PROFILE (77) // Fix track id -#define RTMP_VIDEO_TRACK_ID 0 -#define RTMP_AUDIO_TRACK_ID 1 -#define RTMP_DATA_TRACK_ID 2 +#define RTMP_VIDEO_TRACK_ID 0 +#define RTMP_AUDIO_TRACK_ID 1 +#define RTMP_DATA_TRACK_ID 2 namespace pvd { @@ -33,7 +32,7 @@ namespace pvd { public: static std::shared_ptr Create(StreamSourceType source_type, uint32_t channel_id, const std::shared_ptr &client_socket, const std::shared_ptr &provider); - + explicit RtmpStream(StreamSourceType source_type, uint32_t channel_id, std::shared_ptr client_socket, const std::shared_ptr &provider); ~RtmpStream() final; @@ -66,7 +65,6 @@ namespace pvd bool OnAmfDeleteStream(const std::shared_ptr &header, AmfDocument &document, double transaction_id); bool OnAmfMetaData(const std::shared_ptr &header, const AmfProperty *property); - // Send messages bool SendData(const std::shared_ptr &data); bool SendData(const void *data, size_t data_size); @@ -85,11 +83,11 @@ namespace pvd bool SendAmfOnFCPublish(uint32_t chunk_stream_id, uint32_t stream_id, double client_id); bool SendAmfCreateStreamResult(uint32_t chunk_stream_id, double transaction_id); bool SendAmfOnStatus(uint32_t chunk_stream_id, - uint32_t stream_id, - const char *level, - const char *code, - const char *description, - double client_id); + uint32_t stream_id, + const char *level, + const char *code, + const char *description, + double client_id); // Parsing handshake messages off_t ReceiveHandshakePacket(const std::shared_ptr &data); @@ -126,7 +124,7 @@ namespace pvd // RTMP related RtmpHandshakeState _handshake_state = RtmpHandshakeState::Uninitialized; - + std::shared_ptr _import_chunk; std::shared_ptr _export_chunk; std::shared_ptr _media_info; @@ -151,7 +149,7 @@ namespace pvd std::shared_ptr _signed_policy = nullptr; std::shared_ptr _admission_webhooks = nullptr; - ov::String _full_url; // with stream_name + ov::String _full_url; // with stream_name ov::String _tc_url; ov::String _app_name; ov::String _domain_name; @@ -159,7 +157,7 @@ namespace pvd ov::String _stream_name; ov::String _device_string; - std::shared_ptr _publish_url = nullptr; // AccessControl can redirect url set in RTMP to another url. + std::shared_ptr _publish_url = nullptr; // AccessControl can redirect url set in RTMP to another url. // Cache (GetApplicationInfo()->GetId()) info::application_id_t _app_id = 0; @@ -168,7 +166,7 @@ namespace pvd std::shared_ptr _remote = nullptr; // Received data buffer - std::shared_ptr _remained_data = nullptr; + std::shared_ptr _remained_data = nullptr; // Singed Policy uint64_t _stream_expired_msec = 0; @@ -184,7 +182,7 @@ namespace pvd int64_t _last_audio_pts = 0; ov::StopWatch _last_audio_pts_clock; - // For statistics + // For statistics time_t _stream_check_time = 0; uint32_t _key_frame_interval = 0; @@ -203,4 +201,4 @@ namespace pvd bool _is_incoming_timestamp_used = false; }; -} \ No newline at end of file +} // namespace pvd