UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
ihdtv.h
Go to the documentation of this file.
1/*
2 * FILE: ihdtv/ihdtv.h
3 * AUTHORS: Martin Benes <martinbenesh@gmail.com>
4 * Lukas Hejtmanek <xhejtman@ics.muni.cz>
5 * Petr Holub <hopet@ics.muni.cz>
6 * Milos Liska <xliska@fi.muni.cz>
7 * Jiri Matela <matela@ics.muni.cz>
8 * Dalibor Matura <255899@mail.muni.cz>
9 * Ian Wesley-Smith <iwsmith@cct.lsu.edu>
10 *
11 * Copyright (c) 2005-2209 CESNET z.s.p.o.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, is permitted provided that the following conditions
15 * are met:
16 *
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 *
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
23 *
24 * 3. All advertising materials mentioning features or use of this software
25 * must display the following acknowledgement:
26 *
27 * This product includes software developed by CESNET z.s.p.o.
28 *
29 * 4. Neither the name of CESNET nor the names of its contributors may be used
30 * to endorse or promote products derived from this software without specific
31 * prior written permission.
32 *
33 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS
34 * "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
35 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
36 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
37 * EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
38 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
39 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
40 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
41 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
42 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
43 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
44 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45 *
46 *
47 */
48
49#ifdef HAVE_CONFIG_H
50#include "config.h"
51#include "config_unix.h"
52#include "config_win32.h"
53#endif // HAVE_CONFIG_H
54
55#ifndef _WIN32
56
57#ifndef _IHDTV_H_
58#define _IHDTV_H_
59
60#include <ctype.h>
61
62#include "types.h"
63
64#ifdef __cplusplus
65extern "C" {
66#endif
67
69
70typedef struct {
71 uint32_t stream_id;
72 uint32_t offset; // offset into frame
73 uint64_t frame_number;
74 uint8_t data[65520];
75} __attribute__((packed)) ihdtv_packet;
76
77typedef struct {
78 unsigned int rx_port_1; // receiving ports
79 unsigned int rx_port_2;
80
81 unsigned int tx_port;
82
85 uint64_t current_frame; // internal use
86
87 unsigned long bytes_per_frame;
88 unsigned long bytes_per_half_frame;
89
90 long video_data_per_packet; // size of ihdtv_packet.data used
91 long video_data_per_last_packet; // size of the last packet of each half of a frame
92
93// private:
96
99
100 int pending_packet; // flag of pending packet (ppacket)
101 ihdtv_packet ppacket; // first packet of actual frame in case it came before the end of previous frame(partly lost in ether)
102 unsigned int ppacket_size;
103 unsigned int ppacket_offset_add; // we use this to distinguish between upper and lower half of a frame
104
105
106 struct sockaddr_in target_sockaddress_1;
107 struct sockaddr_in target_sockaddress_2;
108
109 int check_peer_ip; // if set, in rx mode we check, whether the sender address is one of peers addresses
110 struct in_addr peer_address_1;
111 struct in_addr peer_address_2;
113
114int
115ihdtv_init_rx_session(ihdtv_connection *connection, const char* address_1, const char* address_2, unsigned int port1, unsigned int port2, long mtu);
116
117int
118ihdtv_init_tx_session(ihdtv_connection* connection, const char *address_1, const char *address_2, long mtu);
119
120
121int
122ihdtv_receive(ihdtv_connection *rx_connection, char *buffer, unsigned long buffer_length);
123
124int
125ihdtv_send(ihdtv_connection *tx_connection, struct video_frame *tx_frame, unsigned long buffer_length);
126
127#ifdef __cplusplus
128}
129#endif
130
131#endif
132
133#endif // _WIN32
134
int ihdtv_init_rx_session(ihdtv_connection *connection, const char *address_1, const char *address_2, unsigned int port1, unsigned int port2, long mtu)
Definition ihdtv.c:67
void ihdtv_receive_frames(void)
int ihdtv_send(ihdtv_connection *tx_connection, struct video_frame *tx_frame, unsigned long buffer_length)
Definition ihdtv.c:269
int ihdtv_init_tx_session(ihdtv_connection *connection, const char *address_1, const char *address_2, long mtu)
Definition ihdtv.c:190
int ihdtv_receive(ihdtv_connection *rx_connection, char *buffer, unsigned long buffer_length)
Definition ihdtv.c:392
struct __attribute__((packed))
Definition rtp.h:88
uint32_t stream_id
Definition ihdtv.h:71
uint64_t frame_number
Definition ihdtv.h:73
uint32_t offset
Definition ihdtv.h:72
uint64_t current_frame
Definition ihdtv.h:85
int tx_socket_2
Definition ihdtv.h:98
unsigned int video_packets_per_frame
Definition ihdtv.h:83
unsigned long bytes_per_frame
Definition ihdtv.h:87
unsigned int ppacket_offset_add
Definition ihdtv.h:103
int tx_socket_1
Definition ihdtv.h:97
unsigned int ppacket_size
Definition ihdtv.h:102
long video_data_per_packet
Definition ihdtv.h:90
unsigned int rx_port_2
Definition ihdtv.h:79
int pending_packet
Definition ihdtv.h:100
unsigned int tx_port
Definition ihdtv.h:81
unsigned int rx_port_1
Definition ihdtv.h:78
int check_peer_ip
Definition ihdtv.h:109
ihdtv_packet ppacket
Definition ihdtv.h:101
unsigned long bytes_per_half_frame
Definition ihdtv.h:88
unsigned int video_packets_per_half_frame
Definition ihdtv.h:84
int rx_socket_1
Definition ihdtv.h:94
int rx_socket_2
Definition ihdtv.h:95
long video_data_per_last_packet
Definition ihdtv.h:91
Struct video_frame represents a video frame and contains video description.
Definition types.h:305