Skip to content

Commit

Permalink
examples: Improve documentation in V3C examples
Browse files Browse the repository at this point in the history
  • Loading branch information
tampsa committed Jan 30, 2024
1 parent 13037fa commit d0b03af
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 17 deletions.
9 changes: 9 additions & 0 deletions examples/v3c/v3c_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion examples/v3c_receiver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <fstream>
#include <chrono>

/* 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.
Expand Down
37 changes: 21 additions & 16 deletions examples/v3c_sender.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,49 +10,54 @@

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<v3c_unit_info> &units, rtp_flags_t flags, int fmt);

std::atomic<uint64_t> 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;
v3c_file_map mmap;

/* 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;

Expand Down

0 comments on commit d0b03af

Please sign in to comment.