2 mediastreamer2 library - modular sound and video processing and streaming
3 Copyright (C) 2006 Simon MORLAT (simon.morlat@linphone.org)
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #include "mediastreamer2/msqueue.h"
21 #include "mediastreamer2/mscommon.h"
22 #include "mediastreamer2/msvideo.h"
25 MSQueue * ms_queue_new(struct _MSFilter *f1, int pin1, struct _MSFilter *f2, int pin2 ){
26 MSQueue *q=(MSQueue*)ms_new(MSQueue,1);
35 void ms_queue_init(MSQueue *q){
43 void ms_queue_destroy(MSQueue *q){
48 void ms_queue_flush(MSQueue *q){
53 void ms_bufferizer_init(MSBufferizer *obj){
58 MSBufferizer * ms_bufferizer_new(){
59 MSBufferizer *obj=(MSBufferizer *)ms_new(MSBufferizer,1);
60 ms_bufferizer_init(obj);
64 void ms_bufferizer_put(MSBufferizer *obj, mblk_t *m){
65 obj->size+=msgdsize(m);
69 void ms_bufferizer_put_from_queue(MSBufferizer *obj, MSQueue *q){
71 while((m=ms_queue_get(q))!=NULL){
72 ms_bufferizer_put(obj,m);
76 int ms_bufferizer_read(MSBufferizer *obj, uint8_t *data, int datalen){
77 if (obj->size>=datalen){
80 mblk_t *m=peekq(&obj->q);
81 /*we can return something */
83 cplen=MIN(m->b_wptr-m->b_rptr,datalen-sz);
84 memcpy(data+sz,m->b_rptr,cplen);
87 if (m->b_rptr==m->b_wptr){
89 if (m->b_cont!=NULL) {
93 mblk_t *remove=getq(&obj->q);
105 void ms_bufferizer_flush(MSBufferizer *obj){
110 void ms_bufferizer_uninit(MSBufferizer *obj){
114 void ms_bufferizer_destroy(MSBufferizer *obj){
115 ms_bufferizer_uninit(obj);