2009-10-20 Chris Toshok <toshok@ximian.com>
[moon.git] / src / http-streaming.cpp
blob2681662f8e60fb2798662edd9c27b41dfd91c666
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3 * http-streaming.cpp:
5 * Contact:
6 * Moonlight List (moonlight-list@lists.ximian.com)
8 * Copyright 2008 Novell, Inc. (http://www.novell.com)
10 * See the LICENSE file included with the distribution for details.
14 #include <config.h>
16 #include <string.h>
18 #include "http-streaming.h"
19 #include "debug.h"
22 static const char * features [] = {"broadcast", "last", "live", "playlist", "reliable", "seekable", "skipbackwards", "skipforward", "stridable", NULL};
24 HttpStreamingFeatures
25 parse_http_streaming_features (const char *val)
27 HttpStreamingFeatures result = HttpStreamingFeaturesNone;
28 size_t length = 0;
29 bool end = false;
31 LOG_HTTPSTREAMING ("parse_http_streaming_features ('%s')\n", val);
33 if (val == NULL)
34 return result;
36 if (val [0] == '"')
37 val++;
39 while (!end) {
40 end = (val [length] == 0 || val [length] == '"');
41 if (end || val [length] == ',') {
43 //printf ("Checking feature: '%.*s'\n", length, val + start);
45 for (int i = 0; features [i] != NULL; i++) {
46 if (length != strlen (features [i]))
47 continue;
49 if (strncmp (val, features [i], length) == 0) {
50 result = (HttpStreamingFeatures) (result | (1 << i));
51 break;
54 //printf ("Features: '%i'\n", results);
56 val += length + 1;
57 length = 0;
58 } else {
59 length++;
63 return result;