summaryrefslogtreecommitdiff
path: root/media/profile.cpp
blob: 8c9df6f4f91d76432701cd8857f9bf3f8236615b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
 * profile.cpp
 *
 *  Created on: 05.08.2012
 *      Author: savop
 */

#include "../include/media/profile.h"
#include <sstream>
#include <bitset>

using namespace upnp;

ProtocolInfo::ProtocolInfo()
: streamType(DLNA_STREAM_HTTP)
, contentType(string())
, fourthField(DLNA4thField())
{
}

ProtocolInfo::ProtocolInfo(string ct, DLNA4thField ffld, StreamType t)
: streamType(t)
, contentType(ct)
, fourthField(ffld)
{
}

string ProtocolInfo::ToString(){
  if(contentType.empty()) return string();

  stringstream ss;
  switch(streamType){
  case DLNA_STREAM_HTTP:
    ss << "http-get:";
    break;
  case DLNA_STREAM_RTP:
    ss << "rtsp-rtp-udp:";
    break;
  }

  ss << "*:";

  ss << contentType << ":";

  ss << fourthField.ToString();

  return ss.str();
}

DLNA4thField::DLNA4thField()
: profile(string())
, operations(DLNA_OPERATION_NONE)
, playSpeeds(DLNA_PLAYSPEEDS_NONE)
, conversionIndicator(DLNA_CONVERSION_NONE)
, primaryFlags(DLNA_FLAG_NONE)
{
}

DLNA4thField::DLNA4thField(string pn, uint8_t op, string ps, bool ci, uint32_t flags)
: profile(pn)
, operations(op)
, playSpeeds(ps)
, conversionIndicator(ci)
, primaryFlags(flags)
{
}

string DLNA4thField::ToString(){
  if(profile.empty()) return "*";

  stringstream ss;
  ss << "DLNA.ORG_PN=" << profile;

  if(primaryFlags){
    ss << ";";

    ss << "DLNA.ORG_OP=" << bitset<2>(operations) << ";";

    ss << "DLNA.ORG_CI=" << bitset<1>(conversionIndicator) << ";";

    ss << "DLNA.ORG_FLAGS=" << hex << primaryFlags << "000000000000000000000000";
  }

  return ss.str();
}

image::cIcon image::DLNA_ICON_PNG_SM_24A = { "image/png", 48, 48, 24 };
image::cIcon image::DLNA_ICON_PNG_LRG_24A = { "image/png", 120, 120, 24 };

image::cIcon image::DLNA_ICON_JPEG_SM_24 = { "image/jpeg", 48, 48, 24 };
image::cIcon image::DLNA_ICON_JPEG_LRG_24 = { "image/jpeg", 120, 120, 24 };