napa-baselibs / tests / Broadcaster / peer.h @ 507372bb
History | View | Annotate | Download (3.06 KB)
1 |
#ifndef _PEER_H
|
---|---|
2 |
#define _PEER_H
|
3 |
|
4 |
/** @file peer.h
|
5 |
*
|
6 |
* Local header file defining nuts 'n bolts for the peer implementation.
|
7 |
*
|
8 |
*/
|
9 |
|
10 |
#define _GNU_SOURCE
|
11 |
#define ATTRIBUTES_HEADER_SIZE 16 |
12 |
|
13 |
#include <stdio.h> |
14 |
#include <stdlib.h> |
15 |
#include <string.h> |
16 |
#include <math.h> |
17 |
|
18 |
#include <event2/event.h> |
19 |
#include <event2/buffer.h> |
20 |
#include <event2/bufferevent.h> |
21 |
#include <event2/http.h> |
22 |
#include <event2/http_struct.h> |
23 |
#include <confuse.h> |
24 |
|
25 |
#include <napa.h> |
26 |
#include <napa_log.h> |
27 |
#include <ml.h> |
28 |
#include <mon.h> |
29 |
#include <chunk.h> |
30 |
#include <msg_types.h> |
31 |
|
32 |
#include "crc.h" |
33 |
|
34 |
/** Declarations for per-section config definitions */
|
35 |
extern cfg_opt_t cfg_ml[];
|
36 |
extern cfg_opt_t cfg_mon[];
|
37 |
extern cfg_opt_t cfg_rep[];
|
38 |
extern cfg_opt_t cfg_som[];
|
39 |
extern cfg_opt_t cfg_source[];
|
40 |
extern cfg_opt_t cfg_playout[];
|
41 |
|
42 |
/** We store the local peer ID here */
|
43 |
extern char LocalPeerID[]; |
44 |
|
45 |
/** Repository client handle */
|
46 |
extern HANDLE repository;
|
47 |
|
48 |
/** Channel we broadcast/receive */
|
49 |
extern char *channel; |
50 |
|
51 |
/** The ChunkBuffer we share */
|
52 |
extern struct chunk_buffer *chunkbuffer; |
53 |
|
54 |
/** Version string */
|
55 |
extern char version[]; |
56 |
|
57 |
/** Default send parameters for ML */
|
58 |
extern send_params sendParams;
|
59 |
|
60 |
/** Initialize the ML related parts of the Peer
|
61 |
|
62 |
@param[in] libconfuse-parsed "network" section of the config
|
63 |
@param[in] port value, if not 0, it overrides the config file
|
64 |
*/
|
65 |
void ml_init(cfg_t *ml_config, int port); |
66 |
|
67 |
/** Initialize the MONL related parts of the Peer
|
68 |
|
69 |
@param[in] libconfuse-parsed "mon" section of the config
|
70 |
@param[in] channel channel name
|
71 |
*/
|
72 |
void mon_init(cfg_t *mon_config, char* channel); |
73 |
|
74 |
/** Let the monitoring code set its configuration validators
|
75 |
|
76 |
@param[in] config un-parsed configuration.
|
77 |
*/
|
78 |
void mon_validate_cfg(cfg_t *config);
|
79 |
|
80 |
/** Activate the MONL measurements for a new connection *
|
81 |
|
82 |
@param[in] remsocketiID the socket ID for the new connection
|
83 |
*/
|
84 |
void activateMeasurements(socketID_handle remsocketID);
|
85 |
|
86 |
/** Initialize the repoclient related parts of the Peer
|
87 |
|
88 |
@param[in] libconfuse-parsed "repository" section of the config
|
89 |
*/
|
90 |
void rep_init(cfg_t *rep_config);
|
91 |
|
92 |
/** Initialize the "source" functionality (i.e. generating Chunks) of the Peer
|
93 |
|
94 |
@param[in] libconfuse-parsed "source" section of the config
|
95 |
*/
|
96 |
void src_init(cfg_t *source_cfg);
|
97 |
|
98 |
/** Initialize the "playout" functionality (i.e. streaming out) of the Peer
|
99 |
|
100 |
@param[in] libconfuse-parsed "source" section of the config
|
101 |
*/
|
102 |
void playout_init(cfg_t *playout_cfg);
|
103 |
|
104 |
/** Play out the chunk received
|
105 |
|
106 |
@param[in] c the chunk
|
107 |
*/
|
108 |
void playout_chunk(const struct chunk *c); |
109 |
|
110 |
/** Convenience function to publish a measurement record
|
111 |
|
112 |
@param[in] mr the MeasurementRecord
|
113 |
@param[in] msg message to display if an error occurs
|
114 |
*/
|
115 |
|
116 |
void publishMeasurementRecord(MeasurementRecord *mr, char *msg); |
117 |
|
118 |
/** Convenience function to print a string array
|
119 |
|
120 |
@param[in] list the string array to print
|
121 |
@param[in] n numer of items in the array
|
122 |
@param[in] should_free if true, the list (and its elements) are freed after printing
|
123 |
@return the array as a string in a static buffer
|
124 |
*/
|
125 |
const char *print_list(char **list, int n, bool should_free); |
126 |
|
127 |
#endif
|