From d0b03af24bf1582fd503bd948e15e34fc2840804 Mon Sep 17 00:00:00 2001 From: Heikki Tampio Date: Fri, 12 Jan 2024 15:56:22 +0200 Subject: [PATCH] examples: Improve documentation in V3C examples --- examples/v3c/v3c_util.cc | 9 +++++++++ examples/v3c_receiver.cc | 2 +- examples/v3c_sender.cc | 37 +++++++++++++++++++++---------------- 3 files changed, 31 insertions(+), 17 deletions(-) diff --git a/examples/v3c/v3c_util.cc b/examples/v3c/v3c_util.cc index 05bee4ed..ff603ea4 100644 --- a/examples/v3c/v3c_util.cc +++ b/examples/v3c/v3c_util.cc @@ -250,6 +250,10 @@ void parse_v3c_header(v3c_unit_header &hdr, char* buf, uint64_t ptr) uint64_t get_size(std::string filename) { std::ifstream infile(filename, std::ios_base::binary); + if (!infile.is_open()) { + std::cout << "File not found" << std::endl; + return 0; + } //get length of file infile.seekg(0, infile.end); @@ -263,6 +267,11 @@ char* get_cmem(std::string filename) { std::ifstream infile(filename, std::ios_base::binary); + if (!infile.is_open()) { + std::cout << "File not found" << std::endl; + return 0; + } + //get length of file infile.seekg(0, infile.end); size_t length = infile.tellg(); diff --git a/examples/v3c_receiver.cc b/examples/v3c_receiver.cc index ca081c54..4168a184 100644 --- a/examples/v3c_receiver.cc +++ b/examples/v3c_receiver.cc @@ -6,7 +6,7 @@ #include #include -/* This example demonstrates receiving V3C Sample Stream via uvgRTP. It can be used to send V-PCC encoded files, but with +/* This example demonstrates receiving a V3C Sample Stream via uvgRTP. It can be used to send V-PCC encoded files, but with * minor modifications (addition of V3C_CAD and V3C_PVD streams) it can be used also for MIV encoded files. See the comments * in v3c_sender for more comprehensive documentation on V3C RTP streaming. diff --git a/examples/v3c_sender.cc b/examples/v3c_sender.cc index bc83a12c..0d36d32f 100644 --- a/examples/v3c_sender.cc +++ b/examples/v3c_sender.cc @@ -10,42 +10,44 @@ constexpr char REMOTE_ADDRESS[] = "127.0.0.1"; -// Path to the V3C file that you want to send -std::string PATH = ""; +// Path to the V-PCC file that you want to send +std::string PATH = "longdress.vpcc"; void sender_func(uvgrtp::media_stream* stream, const char* cbuf, const std::vector &units, rtp_flags_t flags, int fmt); std::atomic bytes_sent; int main(void) { - /* This example demonstrates sending a file that is in the V3C sample stream format via uvgRTP. It can be used to send V-PCC - * encoded files, but with minor modifications (addition of V3C_CAD and V3C_PVD streams) it can be used also for MIV + /* This example demonstrates transmitting a file that is in the V3C sample stream format via uvgRTP. It can be used to transmit + * V-PCC encoded files, but with minor modifications (addition of V3C_CAD and V3C_PVD streams) it can also be used for MIV * encoded files. * - * The V3C Sample Stream contains a V3C Sample Stream - * header byte and multiple V3C Units with their sizes specified before each unit. A V3C Unit then contains a V3C header - * and Atlas or Video NAL units, depending on the V3C unit type. Video data can be either AVC, HEVC or VVC encoded. This - * example uses HEVC encoding. Using AVC or VVC requires you to set the media streams payload format accordingly. + * The V3C sample stream contains a V3C sample stream header byte and multiple V3C Units with their sizes specified before + * each unit. A V3C Unit then contains a V3C header and Atlas or Video NAL units, depending on the V3C unit type. Video + * data can be either AVC, HEVC or VVC encoded. By default this example uses HEVC encoding. Using AVC or VVC only requires + * you to set the media streams payload format accordingly. * - * The process of sending and receiving a V3C Sample Stream file via uvgRTP contains the following steps: + * The process of sending and receiving a V3C sample stream via uvgRTP contains the following steps: * Parse file and extract locations and sizes of NAL units -> Send NAL units in separate uvgRTP media streams * -> Receive NAL units -> Reconstruct V3C Sample Stream * * In this example there are in total 5 media streams, one for each component: - * 1. Parameter set stream (NOTE: Parameter set should be carried via a signaling protocol such as SDP. It is only - * transmitted using RTP for the simplicity of this demonstration.) + * 1. Parameter set stream (NOTE: Parameter set should be carried via a signaling protocol such as SDP at the start of the + stream. In this demonstration, it is only transmitted using an RTP stream for simplicity.) * 2. Atlas stream * 3. Occupancy Video stream * 4. Geometry Video stream * 5. Attribute Video Stream * * There is also the possibility to have two more streams: Packed Video and Common Atlas Data. These are not included in - * this example as our test files (V-PCC) don't have them. If you need these (MIV), it should be quite easy to implement them + * this example as V-PCC files don't have them. If you need these (MIV), it is easy to add them * A few notes for users: - - This example expects there to be no packet loss. If some NAL units are lost in transmission, - the reconstruction will not work. - - Please also read the documentation on v3c_receiver.cc before testing this example. - - Use RTP_NO_H26X_SCL when sending video frames, as there is no start codes in the video sub-streams + - This demonstration expects there to be no packet loss. If some NAL units are lost in transmission, + issues may occur in the reconstruction + - Please also read the documentation on v3c_receiver.cc before testing this example. + - The information in V3C unit headers is also supposed to be transmitted once at the start of the stream via SDP. For + simplicity, in this example they are just deduced at the receiver. + - Remember to use RTP_NO_H26X_SCL flag when sending video frames, as there is no start codes in the video sub-streams - v3c_sender and v3c_receiver programs use common functions defined in v3c_util. */ bytes_sent = 0; @@ -53,6 +55,9 @@ int main(void) /* Read the file and its size */ uint64_t len = get_size(PATH); + if (len == 0) { + return EXIT_FAILURE; + } char* cbuf = get_cmem(PATH); std::cout << "Parsing V3C file, size " << len << std::endl;