/* -*- 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 #include 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 &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; }