diff --git a/gui/src/main.cpp b/gui/src/main.cpp index 2b536a3..79cd97a 100644 --- a/gui/src/main.cpp +++ b/gui/src/main.cpp @@ -29,6 +29,7 @@ void video_sample_cb(uint8_t *buf, size_t buf_size, void *user) if(!video_out_file) return; printf("writing %#zx to file, start: %#zx\n", buf_size, file_size); + chiaki_log_hexdump(nullptr, CHIAKI_LOG_DEBUG, buf, buf_size); file_size += buf_size; video_out_file->write((const char *)buf, buf_size); //StreamRelayIODevice *io_device = reinterpret_cast(user); @@ -121,4 +122,4 @@ int main(int argc, char *argv[]) return ret; -} +} \ No newline at end of file diff --git a/lib/src/frameprocessor.c b/lib/src/frameprocessor.c index 0f238a2..76cb2b4 100644 --- a/lib/src/frameprocessor.c +++ b/lib/src/frameprocessor.c @@ -155,7 +155,9 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_frame_processor_put_unit(ChiakiFrameProcess } unit->data_size = packet->data_size; - memcpy(frame_processor->frame_buf + packet->unit_index, packet->data, packet->data_size); + memcpy(frame_processor->frame_buf + packet->unit_index * frame_processor->buf_size_per_unit, + packet->data, + packet->data_size); if(packet->unit_index < frame_processor->units_regular_expected) frame_processor->units_regular_received++; diff --git a/lib/src/takion.c b/lib/src/takion.c index 5eb5b37..dd3c40f 100644 --- a/lib/src/takion.c +++ b/lib/src/takion.c @@ -783,9 +783,9 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_takion_av_packet_parse(ChiakiTakionAVPacket if(packet->is_video) { packet->word_at_0x18 = ntohs(*((uint16_t *)(av + 0))); - packet->adaptive_stream_index = av[2] >> 5; - av += 3; - av_size -= 3; + packet->adaptive_stream_index = av[1] >> 5; + av += 2; + av_size -= 2; } // TODO: parsing for uses_nalu_info_structs (before: packet.byte_at_0x1a) @@ -793,8 +793,8 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_takion_av_packet_parse(ChiakiTakionAVPacket if(packet->is_video) { packet->byte_at_0x2c = av[0]; - av += 2; - av_size -= 2; + //av += 2; + //av_size -= 2; } packet->data = av; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 445d9a4..4cd8ca9 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -6,7 +6,8 @@ add_executable(chiaki-unit main.c http.c rpcrypt.c - gkcrypt.c) + gkcrypt.c + takion.c) target_link_libraries(chiaki-unit chiaki-lib munit) diff --git a/test/main.c b/test/main.c index a2a68a2..b453138 100644 --- a/test/main.c +++ b/test/main.c @@ -20,6 +20,7 @@ extern MunitTest tests_http[]; extern MunitTest tests_rpcrypt[]; extern MunitTest tests_gkcrypt[]; +extern MunitTest tests_takion[]; static MunitSuite suites[] = { { @@ -43,6 +44,13 @@ static MunitSuite suites[] = { 1, MUNIT_SUITE_OPTION_NONE }, + { + "/takion", + tests_takion, + NULL, + 1, + MUNIT_SUITE_OPTION_NONE + }, { NULL, NULL, NULL, 0, MUNIT_SUITE_OPTION_NONE } }; diff --git a/test/takion.c b/test/takion.c new file mode 100644 index 0000000..48f6ca5 --- /dev/null +++ b/test/takion.c @@ -0,0 +1,73 @@ +/* + * This file is part of Chiaki. + * + * Chiaki is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Chiaki is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Chiaki. If not, see . + */ + +#include + +#include + + +static MunitResult test_av_packet_parse(const MunitParameter params[], void *user) +{ + uint8_t packet[] = { + 0x2, 0x0, 0x2d, 0x0, 0x5, 0x0, 0xc0, 0x1c, 0x1, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0xe4, 0x10, 0x3, 0x67, 0x0, 0x29, 0xf3, 0x2f, 0x98, 0xf6, 0x99, 0x82, 0x83, 0x78, 0xdb, 0x29, + 0x43, 0xa9, 0xe5, 0x88, 0xf2, 0x11, 0x4, 0x20, 0xe6, 0x20, 0x96, 0xe9, 0x6, 0xee, 0xd, 0x27, + 0xa1, 0x83, 0x82, 0x88, 0xe6, 0x21, 0x49, 0x2, 0x75, 0x74, 0x32, 0x5b, 0xf6, 0xe9, 0xdc, 0x93, + 0xea, 0x31, 0x88, 0xd, 0x2b, 0x4b, 0x34, 0xf9, 0xec, 0x1b, 0x26, 0xcc, 0xbb, 0xbb, 0x81, 0xf2, + 0xd9, 0x2d, 0x8e, 0xa1, 0xb9, 0xe2, 0xb3, 0xca, 0xb2, 0x7d, 0xa3, 0x31, 0xf0, 0x42, 0xb7, 0xb6, + 0x1e, 0x8f, 0x6d, 0xa2, 0x70, 0x46, 0xfd, 0x7e, 0x9b, 0x60, 0x85, 0xb0, 0xed, 0x4f, 0x20, 0xb5, + 0x1, 0x71, 0xa9, 0xaa, 0x18, 0x6b, 0x2a, 0x90, 0xf3, 0xa7, 0x84, 0x36, 0xfd, 0x6d, 0x14, 0x83, + 0x68, 0xa3, 0x9b, 0x3a, 0xc8, 0xd4, 0x3a, 0x31, 0xa0, 0x9b, 0x61, 0xde, 0xa7, 0xed, 0x46, 0xb4, + 0xa3, 0xdf, 0x3f, 0x44, 0x8f, 0xad, 0x64, 0x9, 0xfc, 0x7a, 0xe7, 0x24, 0xf0, 0xd2, 0x42, 0xd3, + 0x57, 0x5a, 0x76, 0x0, 0xc5, 0xe0, 0x93, 0xa9, 0xf5, 0x32, 0x5d, 0xee, 0xf7, 0x9d + }; + + ChiakiTakionAVPacket av_packet; + + ChiakiErrorCode err = chiaki_takion_av_packet_parse(&av_packet, 2, packet, sizeof(packet)); + munit_assert_int(err, ==, CHIAKI_ERR_SUCCESS); + + munit_assert(av_packet.is_video); + munit_assert_uint16(av_packet.packet_index, ==, 45); + munit_assert_uint16(av_packet.frame_index, ==, 5); + // TODO: uses_nalu_info_structs + munit_assert_uint16(av_packet.unit_index, ==, 6); + munit_assert_uint16(av_packet.units_in_frame_total, ==, 8); + munit_assert_uint16(av_packet.units_in_frame_additional, ==, 1); + munit_assert_uint32(av_packet.codec, ==, 3); +// munit_assert_uint16(av_packet.word_at_0x18, ==, 871); + munit_assert_uint8(av_packet.adaptive_stream_index, ==, 0); +// munit_assert_uint8(av_packet.byte_at_0x2c, ==, 0); + + munit_assert_ptr_equal(av_packet.data, packet + 0x15); + munit_assert_size(av_packet.data_size, ==, 0x99); + + return MUNIT_OK; +} + + +MunitTest tests_takion[] = { + { + "/av_packet_parse", + test_av_packet_parse, + NULL, + NULL, + MUNIT_TEST_OPTION_NONE, + NULL + }, + { NULL, NULL, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL } +}; \ No newline at end of file