1
/* $Id: null_port.c 3664 2011-07-19 03:42:28Z nanang $ */
3
* Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4
* Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
#include <pjmedia/null_port.h>
21
#include <pjmedia/errno.h>
22
#include <pj/assert.h>
24
#include <pj/string.h>
27
#define SIGNATURE PJMEDIA_SIG_PORT_NULL
29
static pj_status_t null_get_frame(pjmedia_port *this_port,
30
pjmedia_frame *frame);
31
static pj_status_t null_put_frame(pjmedia_port *this_port,
32
pjmedia_frame *frame);
33
static pj_status_t null_on_destroy(pjmedia_port *this_port);
36
PJ_DEF(pj_status_t) pjmedia_null_port_create( pj_pool_t *pool,
37
unsigned sampling_rate,
38
unsigned channel_count,
39
unsigned samples_per_frame,
40
unsigned bits_per_sample,
41
pjmedia_port **p_port )
44
const pj_str_t name = pj_str("null-port");
46
PJ_ASSERT_RETURN(pool && p_port, PJ_EINVAL);
48
port = PJ_POOL_ZALLOC_T(pool, pjmedia_port);
49
PJ_ASSERT_RETURN(pool != NULL, PJ_ENOMEM);
51
pjmedia_port_info_init(&port->info, &name, SIGNATURE, sampling_rate,
52
channel_count, bits_per_sample, samples_per_frame);
54
port->get_frame = &null_get_frame;
55
port->put_frame = &null_put_frame;
56
port->on_destroy = &null_on_destroy;
69
static pj_status_t null_put_frame(pjmedia_port *this_port,
72
PJ_UNUSED_ARG(this_port);
79
* Get frame from file.
81
static pj_status_t null_get_frame(pjmedia_port *this_port,
84
frame->type = PJMEDIA_FRAME_TYPE_AUDIO;
85
frame->size = PJMEDIA_PIA_AVG_FSZ(&this_port->info);
86
frame->timestamp.u32.lo += PJMEDIA_PIA_SPF(&this_port->info);
87
pjmedia_zero_samples((pj_int16_t*)frame->buf,
88
PJMEDIA_PIA_SPF(&this_port->info));
97
static pj_status_t null_on_destroy(pjmedia_port *this_port)
99
PJ_UNUSED_ARG(this_port);