1/*
2* Copyright (C) 2011 The Android Open Source Project
3*
4* Licensed under the Apache License, Version 2.0 (the "License");
5* you may not use this file except in compliance with the License.
6* You may obtain a copy of the License at
7*
8* http://www.apache.org/licenses/LICENSE-2.0
9*
10* Unless required by applicable law or agreed to in writing, software
11* distributed under the License is distributed on an "AS IS" BASIS,
12* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13* See the License for the specific language governing permissions and
14* limitations under the License.
15*/
16#include <stdio.h>
17#include <stdlib.h>
18#include <unistd.h>
19#include <string.h>
20#include "codec_defs.h"
21#include "RenderingThread.h"
22#include "TcpStream.h"
23#ifndef _WIN32
24#include "UnixStream.h"
25#endif
26
27
28int main(int argc, char **argv)
29{
30#ifdef _WIN32
31    TcpStream *socket = new TcpStream();
32
33    if (socket->listen(CODEC_SERVER_PORT) < 0) {
34        perror("listen");
35        exit(1);
36    }
37#else
38    UnixStream *socket = new UnixStream();
39
40    if (socket->listen(CODEC_SERVER_PORT) < 0) {
41        perror("listen");
42        exit(1);
43    }
44#endif
45
46    printf("waiting for client connection on port: %d\n", CODEC_SERVER_PORT);
47    while (1) {
48        // wait for client connection
49        SocketStream  *glStream = socket->accept();
50        if (glStream == NULL) {
51            printf("failed to get client.. aborting\n");
52            exit(3);
53        }
54        printf("Got client connection, creating a rendering thread;\n");
55        // create a thread to handle this connection
56        RenderingThread *rt = new RenderingThread(glStream);
57        rt->start();
58    }
59
60    return 0;
61}
62
63
64