Statistics
| Branch: | Revision:

streamers / output-http.c @ a723a046

History | View | Annotate | Download (1.41 KB)

1 8a49328f CsabaKiraly
        /*
2
 *  Copyright (c) 2010 Csaba Kiraly
3
 *
4
 *  This is free software; see gpl-3.0.txt
5
 */
6
#include <stdio.h>
7
#include <stdint.h>
8
#include <stdlib.h>
9
#include <stdbool.h>
10
#include <sys/time.h>
11
#include <chunk.h>
12
#include <net_helper.h>
13
14
#include "http_default_urls.h"
15
#include "external_chunk_transcoding.h"
16
17
#include "output.h"
18
#include "dbg.h"
19
20
#define PLAYER_IP "127.0.0.1"
21
22
struct nodeID *streamer;
23
static char url[256];
24
static int base_port = 0;
25
26
void output_init1(int bufsize, const char *config)
27
{
28
  if(!config) {
29
     fprintf(stderr, "Error: no http output module configuration issued. Exiting\n");
30
     exit(1);
31
  }
32
  if(sscanf(config, "%d", &base_port) < 1) {
33
     fprintf(stderr, "Error: can't parse http output module configuration string %s. Exiting\n", config);
34
     exit(1);
35
  }
36
        //we use the -F portnum parameter as the http port number
37
        sprintf(url, "http://%s:%d%s", PLAYER_IP, base_port, UL_DEFAULT_EXTERNALPLAYER_PATH);
38 4082048b GiuseppeTropea
        initChunkPusher();
39 8a49328f CsabaKiraly
}
40
41
void output_deliver1(const struct chunk *c)
42
{
43
  int ret = -1;
44
45
        //deliver the chunk to the external http player listening on http port
46 cbd3919d Csaba Kiraly
        //which has been setup via the -F option of the streamer commandline
47 8a49328f CsabaKiraly
        //If port was set > 60000 the the http
48
        //deliver is disabled, to allow mixed testing scenarios
49
        if(base_port < 60000) {
50
          ret = sendViaCurl(*c, GRAPES_ENCODED_CHUNK_HEADER_SIZE + c->size + c->attributes_size, url);
51
          dprintf("Chunk %d delivered to %s\n", c->id, url);
52
        }
53
}