Statistics
| Branch: | Revision:

streamers / output-http.c @ 4082048b

History | View | Annotate | Download (1.42 KB)

1
        /*
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
        initChunkPusher();
39
}
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
        //which has been setup via the -F option of the offerstreamer commandline
47
        //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
}