{"id":5727,"date":"2026-05-20T12:00:00","date_gmt":"2026-05-20T03:00:00","guid":{"rendered":"https:\/\/www.freelifemakers.org\/wordpress\/?p=5727"},"modified":"2026-05-20T13:42:34","modified_gmt":"2026-05-20T04:42:34","slug":"mediaserver-mini_mediaserver_1-code-description-1-2","status":"publish","type":"post","link":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/2026\/05\/20\/mediaserver-mini_mediaserver_1-code-description-1-2\/","title":{"rendered":"[Mediaserver]mini_Mediaserver_1-\ucf54\ub4dc\uc124\uba85\/code description-Protocol Control Messages\u00a0-(1-2)"},"content":{"rendered":"\n<p>\ud83d\udc49\ud83c\udffb \uc544\ub798\ub294 miniMediaserver_1\uc758 \ucf54\ub4dc \uc124\uba85\uc785\ub2c8\ub2e4.(rtmp_session.cpp)<br>Below is the code description for miniMediaserver_1 (rtmp_session.cpp).<\/p>\n\n\n\n<p>\ud83d\udc49\ud83c\udffb void RtmpSession::send_protocol_messages() {} \uc774 \ud568\uc218\uc5d0\uc11c Protocol Control Messages&nbsp;\ub97c \ubcf4\ub0c5\ub2c8\ub2e4.<br>void RtmpSession::send_protocol_messages() {} This function sends Protocol Control Messages.<\/p>\n\n\n\n<p>\ud83d\udc49\ud83c\udffb OBS\uac00 \uc11c\ubc84\ub85c \ubcf4\ub0bc \ub370\uc774\ud130 \uc124\uc815 \uac12\uc744 OBS\uc5d0\uac8c \ud1b5\ubcf4\ud569\ub2c8\ub2e4.<br>Notifies OBS of the data setting values \u200b\u200bto send to the server.<\/p>\n\n\n\n<p>\u2714\ufe0f void RtmpSession::send_protocol_messages() {}<\/p>\n\n\n\n<p>&#8212; \ud578\ub4dc\uc170\uc774\ud06c \ub05d\ub098\uc790\ub9c8\uc790 \ubc84\ud37c 5MB, \ub300\uc5ed\ud3ed 5MB\/s, \uccad\ud06c 4KB \uc774\ub807\uac8c \uc14b\ud305\ud55c 3\uac00\uc9c0 \uaddc\uce59\uc744 OBS\ud55c\ud14c \ud1b5\ubcf4\ud558\ub294 \ud568\uc218\uc785\ub2c8\ub2e4.<br>This is a function that notifies OBS of three rules set to 5MB buffer, 5MB\/s bandwidth, and 4KB chunks as soon as the handshake is finished.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1) Window Acknowledgement Size &#8211; type 0x05<\/h3>\n\n\n\n<p>&#8212; obs\uac00 \uc11c\ubc84\uc5d0\uac8c 5Mbyte\uc529 \ub370\uc774\ud130 \ubcf4\ub0b4\uace0 Ack\uae30\ub2e4\ub9ac\ub77c\ub294 \uc14b\ud305 \uac12\uc744 obs\uc5d0\uac8c \uc804\uc1a1 \ud558\ub294 \ubd80\ubd84\uc785\ub2c8\ub2e4.<br>This is the part where a setting value is sent to OBS to send data to the server in 5Mbyte chunks and wait for an ACK.<\/p>\n\n\n\n<p>&#8212; window\ub77c\ub294 \uc758\ubbf8\ub294 Tcp Sliding window\uc5d0\uc11c \uc628 \ub9d0\uc774\uba70 \uba54\uc138\uc9c0 \ud06c\uae30\ub97c \ucc3d\ubb38\uc758 \ud06c\uae30\ucc98\ub7fc \ud45c\ud604\ud55c \uac81\ub2c8\ub2e4.<br>The term &#8220;window&#8221; comes from &#8220;TCP Sliding Window,&#8221; and it refers to the message size being expressed like the size of a window.<\/p>\n\n\n\n<p>&#8212; \ucf54\ub4dc\uc5d0\uc11c \ube68\uac04\uc0c9\uc740 \ud5e4\ub354 \ubd80\ubd84\uc785\ub2c8\ub2e4. Window Ack,Band with, chunk \ubaa8\ub450 \uacf5\ud1b5\uc785\ub2c8\ub2e4.<br>The red parts in the code are the header sections. Window Ack, Band with, and chunk are all common.<\/p>\n\n\n\n<p>1-1. \ub179\uc0c9\uc740 \ub370\uc774\ud130 \ud06c\uae30(5M)\ub97c \ud45c\ud604\ud560 \ubc14\uc774\ud2b8 \uc218(4byte)\uc785\ub2c8\ub2e4.<br>Green is the number of bytes (4 bytes) to represent the data size (5M).<\/p>\n\n\n\n<p>\ub178\ub791\uc0c9\uc740 \uc11c\ubc84\uac00 OBS\uc5d0 \ubcf4\ub0b4\ub294 \uba54\uc138\uc9c0 \ud0c0\uc785\uc785\uc774\ub2e4. <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-black-color\">0x05\ub294 <\/mark>window ack\ub97c \uc758\ubbf8\ud569\ub2c8\ub2e4.<br>The yellow text indicates the message type the server sends to OBS. 0x05 means a window ack.<\/p>\n\n\n\n<p>4byte\ub294 pkt.insert(pkt.end(), (uint8_t*)&amp;ack, (uint8_t*)&amp;ack + 4);\uc774 \ucf54\ub4dc\uc5d0 \ud3ec\ud568\ub418\uc5b4 \uc788\uc2b5\ub2c8\ub2e4.<br>4 bytes are included in this code: pkt.insert(pkt.end(), (uint8_t<em>)&amp;ack, (uint8_t<\/em>)&amp;ack + 4);<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pkt.insert(pkt.end(), {<mark style=\"background-color:rgba(0, 0, 0, 0);color:#bb2c2c\" class=\"has-inline-color\">00x02, 0x00, 0x00, 0x00, 0x00, 0x00<\/mark>, <mark style=\"background-color:rgba(0, 0, 0, 0);color:#4abb28\" class=\"has-inline-color\">0x04<\/mark>, <mark style=\"background-color:rgba(0, 0, 0, 0);color:#d6d915\" class=\"has-inline-color\">0x05<\/mark>, <mark style=\"background-color:rgba(0, 0, 0, 0);color:#1867d3\" class=\"has-inline-color\">0x00, 0x00, 0x00, 0x00<\/mark> } );<\/code><\/pre>\n\n\n\n<p>1-2 htonl()\ud568\uc218\ub97c \uc774\uc6a9\ud574\uc11c \ube45\uc5d4\ub514\uc5b8\uc73c\ub85c \ubc14\uafc9\ub2c8\ub2e4.<br>Convert to big-endian using the htonl() function.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>uint32_t ack = htonl(5000000);<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>5000000 = 0x004C4B40\n\n\ub9ac\ud2c0\uc5d4\ub514\uc548 == PC \uba54\ubaa8\ub9ac(\uac70\uafb8\ub85c\uc800\uc7a5\ub428)\nLittle Endian == PC Memory (stored in reverse order): \n40 4B 4C 00\n\n\ube45\uc5d4\ub514\uc5b8 == \ub124\ud2b8\uc6cc\ud06c\uc21c\uc11c(\ubcf5\uad6c)\nBig Endian == Network Order (Recovery) : \n00 4C 4B 40 <\/code><\/pre>\n\n\n\n<p>1-3 <code>uint32_t<\/code>\ub294 4\ubc14\uc774\ud2b8\uc9dc\ub9ac \ubcc0\uc218\uc778\ub370,&nbsp;<code>uint8_t*<\/code>\ub85c \ubc14\uafb8\uba74 1\ubc14\uc774\ud2b8\uc529 \uc811\uadfc \uac00\ub2a5\ud569\ub2c8\ub2e4.<br>uint32_t is a 4-byte variable, but if you change it to uint8_t*, you can access it 1 byte at a time.<\/p>\n\n\n\n<p>1-4.pkt\uc5d0 (uint8_t*)&amp;ack \ub4a4\uc5d0 1~4\ubc14\uc774\ud2b8\uae4c\uc9c0 1\ubc14\uc774\ud2b8 \uc529 \uc77d\uc5b4\uc11c \ucd94\uac00\ud569\ub2c8\ub2e4.<br>Read bytes 1 through 4 one by one and append them to 1-4.pkt after (uint8_t*)&amp;ack.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>uint32_t ack = htonl(5000000); \npkt.insert(pkt.end(), (uint8_t*)&amp;ack, (uint8_t*)&amp;ack + 4);<\/code><\/pre>\n\n\n\n<p>2)ack\uc5d0 \ud3ec\ud568\uc2dc\ud0a4\uc9c0 \uc54a\uc744 \uacbd\uc6b0 \ub370\uc774\ud130\ub294 \uc544\ub798\ucc98\ub7fc \ud45c\ud604\ud574\ub3c4\ub429\ub2c8\ub2e4. \ub9c8\uc9c0\ub9c9 \uac80\uc740\uc0c9\uc774 16\uc9c4\uc218\ub85c 5Mbyte\ub97c \ud45c\ud604\ud569\ub2c8\ub2e4.<br>If not included in the ack, the data may be expressed as follows. The last black part represents 5 Mbytes in hexadecimal.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pkt.insert(pkt.end(), {\n    <mark style=\"background-color:rgba(0, 0, 0, 0);color:#dc2a2a\" class=\"has-inline-color\">0x02, 0x00, 0x00, 0x00, 0x00, 0x00<\/mark>, <mark style=\"background-color:rgba(0, 0, 0, 0);color:#1bc535\" class=\"has-inline-color\">0x04<\/mark>, <mark style=\"background-color:rgba(0, 0, 0, 0);color:#e6e415\" class=\"has-inline-color\">0x05<\/mark>, <mark style=\"background-color:rgba(0, 0, 0, 0);color:#1b7ed0\" class=\"has-inline-color\">0x00, 0x00, 0x00, 0x00,\n    0x00<\/mark>, 0x4C, 0x4B, 0x40\n});<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">2) \ub300\uc5ed\ud3ed \/ BandWith<\/h3>\n\n\n\n<p>1-1. \ub179\uc0c9\uc740 \ub370\uc774\ud130 \ud06c\uae30(5M)\ub97c \ud45c\ud604\ud560 \ubc14\uc774\ud2b8 \uc218(4byte)\uc785\ub2c8\ub2e4. \ub178\ub791\uc0c9\uc740 \uc11c\ubc84\uac00 OBS\uc5d0 \ubcf4\ub0b4\ub294 \uba54\uc138\uc9c0 \ud0c0\uc785\uc785\uc774\ub2e4. <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-black-color\">0x06\ub294 <\/mark>bandwith \uba54\uc138\uc9c0 \uc784\uc744 \uc758\ubbf8\ud569\ub2c8\ub2e4.<br>Green is the number of bytes (4 bytes) to represent the data size (5M). Yellow is the message type the server sends to OBS. 0x06 means it is a bandwidth message.<\/p>\n\n\n\n<p>1-2. 00 4C 4B 40 = 5000000(5Mbyte) + 02(limite type)<\/p>\n\n\n\n<p>1-3 Limite type<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>00 : hard -&gt; \ubb34\uc870\uac74 \uc9c0\ucf1c\uc57c\ud568 \/ Must be followed unconditionally\n01 : soft -&gt; \uad8c\uc7a5\uc124\uc815 \/ Recommended settings\n02 : Dynamic  -&gt; \uad8c\uc7a5\uc124\uc815 \ud558\uc9c0\ub9cc OBS \uc804\uc1a1\uc5d0 \ub9de\ucda4 \/ Recommended settings, but customized for OBS transmission<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>pkt.insert(pkt.end(), {<mark style=\"background-color:rgba(0, 0, 0, 0);color:#d92525\" class=\"has-inline-color\">0x02, 0x00, 0x00, 0x00, 0x00, 0x00<\/mark>, <mark style=\"background-color:rgba(0, 0, 0, 0);color:#1fcc67\" class=\"has-inline-color\">0x05<\/mark>, <mark style=\"background-color:rgba(0, 0, 0, 0);color:#dcd81d\" class=\"has-inline-color\">0x06<\/mark>, <mark style=\"background-color:rgba(0, 0, 0, 0);color:#135fd9\" class=\"has-inline-color\">0x00, 0x00, 0x00, 0x00<\/mark>});<\/code><\/pre>\n\n\n\n<p>1-4. htonl()\ud568\uc218\ub97c \uc774\uc6a9\ud574\uc11c \ube45\uc5d4\ub514\uc5b8\uc73c\ub85c \ubc14\uafc9\ub2c8\ub2e4.<br>Convert to big-endian using the htonl() function.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>uint32_t bw = htonl(5000000); <\/code><\/pre>\n\n\n\n<p>1-5. pkt\uc5d0 (uint8_t*)&amp;ack \ub4a4\uc5d0 1~4\ubc14\uc774\ud2b8\uae4c\uc9c0 1\ubc14\uc774\ud2b8 \uc529 \uc77d\uc5b4\uc11c \ucd94\uac00\ud569\ub2c8\ub2e4. <br>\ub9c8\uc9c0\ub9c9\uc5d0 pkt.push_back(0x02); \uc774\ub807\uac8c limit type\ucd94\uac00\ud574\uc11c 5byte\ub97c \uc644\uc131\ud569\ub2c8\ub2e4.<br>Read bytes 1 through 4 one by one and append them to pkt after (uint8_t*)&amp;ack. <br>Finally, add limit type like pkt.push_back(0x02); to complete the 5 bytes.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>    pkt.insert(pkt.end(), (uint8_t*)&amp;bw, (uint8_t*)&amp;bw + 4);\n    pkt.push_back(0x02);<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">3) Chunk<\/h3>\n\n\n\n<p>1-1. \ub179\uc0c9\uc740 \ub370\uc774\ud130 \ud06c\uae30(5M)\ub97c \ud45c\ud604\ud560 \ubc14\uc774\ud2b8 \uc218(4byte)\uc785\ub2c8\ub2e4. \ub178\ub791\uc0c9\uc740 \uc11c\ubc84\uac00 OBS\uc5d0 \ubcf4\ub0b4\ub294 \uba54\uc138\uc9c0 \ud0c0\uc785\uc785\uc774\ub2e4. <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-black-color\">0x01\ub294 <\/mark>chunk \uba54\uc138\uc9c0 \uc784\uc744 \uc758\ubbf8\ud569\ub2c8\ub2e4.<br>Green is the number of bytes (4 bytes) representing the data size (5M). Yellow is the message type the server sends to OBS. 0x01 means it is a chunk message.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pkt.insert(pkt.end(), {<mark style=\"background-color:rgba(0, 0, 0, 0);color:#d72020\" class=\"has-inline-color\">0x02, 0x00, 0x00, 0x00, 0x00, 0x00<\/mark>, <mark style=\"background-color:rgba(0, 0, 0, 0);color:#11d221\" class=\"has-inline-color\">0x04,<\/mark> <mark style=\"background-color:rgba(0, 0, 0, 0);color:#dfc91a\" class=\"has-inline-color\">0x01<\/mark>, <mark style=\"background-color:rgba(0, 0, 0, 0);color:#106fd2\" class=\"has-inline-color\">0x00, 0x00, 0x00, 0x00<\/mark>});<\/code><\/pre>\n\n\n\n<p>1-2. htonl()\ud568\uc218\ub97c \uc774\uc6a9\ud574\uc11c \ube45\uc5d4\ub514\uc5b8\uc73c\ub85c \ubc14\uafc9\ub2c8\ub2e4. 4096\uc740 RTMP \ud504\ub85c\ud1a0\ucf5c\uc5d0\uc11c OBS\uc5d0\uc11c \uc11c\ubc84\ub85c \ubcf4\ub0bc \uba54\uc138\uc9c0 \ub2e8\uc704 \uc785\ub2c8\ub2e4.<br>Convert to big-endian using the htonl() function. 4096 is the message unit that OBS sends to the server in the RTMP protocol.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>uint32_t cs = htonl(4096); <\/code><\/pre>\n\n\n\n<p>1-3. pkt\uc5d0 (uint8_t*)&amp;ack \ub4a4\uc5d0 1~4\ubc14\uc774\ud2b8\uae4c\uc9c0 1\ubc14\uc774\ud2b8 \uc529 \uc77d\uc5b4\uc11c \ucd94\uac00\ud569\ub2c8\ub2e4.<br>Reads bytes 1 through 4 one by one and appends them to pkt after (uint8_t*)&amp;ack.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pkt.insert(pkt.end(), (uint8_t*)&amp;cs, (uint8_t*)&amp;cs + 4);<\/code><\/pre>\n\n\n\n<p>4)Protocol Control Messages \uc804\uc1a1\ud558\uae30<br>Sending Protocol Control Messages<\/p>\n\n\n\n<p>&#8212; \uc704\uc5d0\uc11c \uc124\uc815\ub41c pkt\ub97c OBS\ub85c \uc804\uc1a1\ud558\uace0 read_chunk_header(); \ud568\uc218\ub97c \uc2e4\ud589\ud569\ub2c8\ub2e4.<br>Send the pkt configured above to OBS and execute the read_chunk_header(); function.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>    asio::async_write(socket_, asio::buffer(pkt),\n        &#91;this, self](std::error_code ec, std::size_t) {\n            if (ec) return;\n            std::cout &lt;&lt; \"&#91;Server] Protocol messages sent\\n\";\n            read_chunk_header();\n        });<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\ud83d\udc49\ud83c\udffb \uc544\ub798\ub294 miniMediaserver_1\uc758 \ucf54\ub4dc \uc124\uba85\uc785\ub2c8\ub2e4.(rtmp_session.cpp)Below is the code description for miniMediaserver_1 (rtmp_session.cpp). \ud83d\udc49\ud83c\udffb void RtmpSession::send_protocol_messages() {} \uc774 \ud568\uc218\uc5d0\uc11c Protocol Control Messages&nbsp;\ub97c \ubcf4\ub0c5\ub2c8\ub2e4.void RtmpSession::send_protocol_messages() {} This function sends Protocol Control Messages. \ud83d\udc49\ud83c\udffb OBS\uac00 \uc11c\ubc84\ub85c \ubcf4\ub0bc \ub370\uc774\ud130 \uc124\uc815 \uac12\uc744 OBS\uc5d0\uac8c \ud1b5\ubcf4\ud569\ub2c8\ub2e4.Notifies OBS of the data setting values \u200b\u200bto send to the server. \u2714\ufe0f void RtmpSession::send_protocol_messages() {} &#8212; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,1],"tags":[],"class_list":["post-5727","post","type-post","status-publish","format-standard","hentry","category-cpp","category-uncategorized","missing-thumbnail"],"_links":{"self":[{"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/5727","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/comments?post=5727"}],"version-history":[{"count":2,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/5727\/revisions"}],"predecessor-version":[{"id":5730,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/5727\/revisions\/5730"}],"wp:attachment":[{"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/media?parent=5727"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/categories?post=5727"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.freelifemakers.org\/wordpress\/index.php\/wp-json\/wp\/v2\/tags?post=5727"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}