Revision c039490c src/pstreamer.c

View differences:

src/pstreamer.c
30 30
	char id[PSID_LENGTH];  // identifier for the streamer instance
31 31
	struct pscontext * psc;
32 32
	time_t last_beat;
33
	uint16_t base_port;
33 34
};
34 35

  
35 36
struct pstreamer_manager {
36 37
	struct ord_set * streamers;
38
	uint16_t next_streaming_port;
37 39
};
38 40

  
39 41
int8_t pstreamer_cmp(const void * v1, const void * v2)
......
65 67
	return res;
66 68
}
67 69

  
68
struct pstreamer_manager * pstreamer_manager_new()
70
struct pstreamer_manager * pstreamer_manager_new(uint16_t starting_port)
69 71
{
70 72
	struct pstreamer_manager * psm = NULL;
71 73

  
72 74
	psm = malloc(sizeof(struct pstreamer_manager));
73 75
	psm->streamers = ord_set_new(1, pstreamer_cmp);
76
	psm->next_streaming_port = starting_port;
74 77

  
75 78
	return psm;
76 79
}
......
101 104
		strncpy(ps->source_ip, source_ip, MAX_IPADDR_LENGTH);
102 105
		strncpy(ps->source_port, source_port, MAX_PORT_LENGTH);
103 106
		strncpy(ps->id, id, PSID_LENGTH);
107
		ps->base_port = psm->next_streaming_port;
108
		psm->next_streaming_port += 4;  // we consider RTP streamers uses 4 ports
104 109
		ptr = ord_set_find(psm->streamers, (const void *) ps);
105 110
		if (ptr == NULL)
106 111
		{
......
126 131

  
127 132
	return res;
128 133
}
134

  
135
const char * pstreamer_id(const struct pstreamer * ps)
136
{
137
	if (ps)
138
		return ps->id;
139
	return NULL;
140
}
141

  
142
uint16_t pstreamer_base_port(const struct pstreamer * ps)
143
{
144
	if (ps)
145
		return ps->base_port;
146
	return 0;
147
}

Also available in: Unified diff