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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set et sw=2 ts=2: */
/***************************************************************************
* rtp_profile_raw.cc
*
* Mon Sep 2 14:30:56 CEST 2013
* Copyright 2013 Bent Bisballe Nyeng
* deva@aasimon.org
****************************************************************************/
/*
* This file is part of lrtp.
*
* lrtp is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* lrtp is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with lrtp; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "rtp_profile_raw.h"
#include "rtp_profile.h"
#include <stdio.h>
#include <string.h>
struct lrtp_profile_raw_t {
struct lrtp_profile_t profile; // 'Inherit' lrtp_profile_t
unsigned short int pkg_size;
};
int profile_raw_pack(struct lrtp_profile_t *profile,
const char *frame, size_t framesize,
RTP &rtp)
{
struct lrtp_profile_raw_t *p = (struct lrtp_profile_raw_t *)profile;
size_t cpsz = p->pkg_size;
if(cpsz > framesize) cpsz = framesize;
rtp.setPayload(frame, cpsz);
return cpsz;
}
int profile_raw_unpack(struct lrtp_profile_t *profile,
const RTP &rtp,
std::list<outputframe_t *> &framelist)
{
struct lrtp_profile_raw_t *p = (struct lrtp_profile_raw_t *)profile;
outputframe_t *of = new outputframe_t();
of->size = rtp.payloadSize();
char *buf = (char*)malloc(of->size);
of->size = rtp.payload(buf, of->size);
of->data = buf;
framelist.push_back(of);
return 0;
}
void profile_raw_destroy(struct lrtp_profile_t *profile)
{
struct lrtp_profile_raw_t *p = (struct lrtp_profile_raw_t *)profile;
delete p;
}
struct lrtp_profile_t *profile_raw_create(struct lrtp_t *lrtp,
unsigned int csrc,
va_list vp)
{
struct lrtp_profile_raw_t *p = new struct lrtp_profile_raw_t;
p->profile.pack = profile_raw_pack;
p->profile.unpack = profile_raw_unpack;
p->profile.destroy = profile_raw_destroy;
p->pkg_size = 100;
while(true) {
int type = va_arg(vp, int);
if(type == OPTION_END) break;
switch(type) {
case OPTION_RAW_PKG_SIZE:
p->pkg_size = va_arg(vp, int);
break;
default:
// TODO: Unknown arg type
break;
}
}
return &p->profile;
}
|