~ubuntu-branches/ubuntu/karmic/mpeg4ip/karmic

« back to all changes in this revision

Viewing changes to lib/mp4/rtp.c

  • Committer: Bazaar Package Importer
  • Author(s): Mario Limonciello
  • Date: 2008-01-12 15:59:56 UTC
  • Revision ID: james.westby@ubuntu.com-20080112155956-1vznw5njidvrh649
Tags: upstream-1.6dfsg
ImportĀ upstreamĀ versionĀ 1.6dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * The contents of this file are subject to the Mozilla Public
 
3
 * License Version 1.1 (the "License"); you may not use this file
 
4
 * except in compliance with the License. You may obtain a copy of
 
5
 * the License at http://www.mozilla.org/MPL/
 
6
 * 
 
7
 * Software distributed under the License is distributed on an "AS
 
8
 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
 
9
 * implied. See the License for the specific language governing
 
10
 * rights and limitations under the License.
 
11
 * 
 
12
 * The Original Code is MPEG4IP.
 
13
 * 
 
14
 * The Initial Developer of the Original Code is Cisco Systems Inc.
 
15
 * Portions created by Cisco Systems Inc. are
 
16
 * Copyright (C) Cisco Systems Inc. 2000, 2001.  All Rights Reserved.
 
17
 * 
 
18
 * Contributor(s): 
 
19
 *              Dave Mackie             dmackie@cisco.com
 
20
 */
 
21
 
 
22
#include "quicktime.h"
 
23
 
 
24
 
 
25
int quicktime_rtp_init(quicktime_rtp_t *rtp)
 
26
{
 
27
        rtp->string = NULL;
 
28
}
 
29
 
 
30
int quicktime_rtp_set(quicktime_rtp_t *rtp, char *string)
 
31
{
 
32
        free(rtp->string);
 
33
        if (string != NULL) {
 
34
                rtp->string = malloc(strlen(string) + 1);
 
35
                strcpy(rtp->string, string);
 
36
        } else {
 
37
                rtp->string = NULL;
 
38
        }
 
39
}
 
40
 
 
41
int quicktime_rtp_append(quicktime_rtp_t *rtp, char *appendString)
 
42
{
 
43
        char* newString = malloc(strlen(rtp->string) + strlen(appendString) + 1);
 
44
 
 
45
        strcpy(newString, rtp->string);
 
46
        strcat(newString, appendString);
 
47
        free(rtp->string);
 
48
        rtp->string = newString;
 
49
}
 
50
 
 
51
int quicktime_rtp_delete(quicktime_rtp_t *rtp)
 
52
{
 
53
        free(rtp->string);
 
54
}
 
55
 
 
56
int quicktime_rtp_dump(quicktime_rtp_t *rtp)
 
57
{
 
58
        printf("    rtp\n");
 
59
        printf("     string %s\n", rtp->string);
 
60
}
 
61
 
 
62
int quicktime_read_rtp(quicktime_t *file, quicktime_rtp_t *rtp, 
 
63
        quicktime_atom_t* rtp_atom)
 
64
{
 
65
        int rtpLen = rtp_atom->size - 12;
 
66
        free(rtp->string);
 
67
        rtp->string = malloc(rtpLen + 1);
 
68
                quicktime_read_int32(file);     // skip the 'sdp '
 
69
        quicktime_read_data(file, rtp->string, rtpLen);
 
70
        rtp->string[rtpLen] = '\0';
 
71
}
 
72
 
 
73
int quicktime_write_rtp(quicktime_t *file, quicktime_rtp_t *rtp)
 
74
{
 
75
        int i;
 
76
        quicktime_atom_t atom;
 
77
 
 
78
        if (rtp->string == NULL) {
 
79
                return;
 
80
        }
 
81
 
 
82
        quicktime_atom_write_header(file, &atom, "rtp ");
 
83
 
 
84
        quicktime_write_data(file, "sdp ", 4);
 
85
        quicktime_write_data(file, rtp->string, strlen(rtp->string));
 
86
 
 
87
        quicktime_atom_write_footer(file, &atom);
 
88
}