void * carmen_mdalloc(int ndim, int width, ...) { va_list argp; int *dims, i; char ***tip; va_start(argp, width); /* allocate storage for variable args (dimensions) */ dims = malloc(ndim*sizeof(int)); /* check_alloc checked */ if(dims == NULL) return NULL; /* initialize dimensions array for subsequent calls */ for(i=0; i<ndim; i++) dims[i] = va_arg(argp,int); w_units = width; /* global used by md2 and md3 */ /* allocate required pointer and array element storage */ tip = (char ***)md2(dims[0], ndim, &dims[1]); if(ndim>1 && tip) md3(tip, dims[0], ndim-1, &dims[1]); /* init pointers */ free(dims); return tip; }
void testMediaDescriptor_TypeAndDirectionality() { const char *sdp = "v=0\r\n" "o=mhandley 2890844526 2890842807 IN IP4 126.16.64.4\r\n" "s=SDP Seminar\r\n" "i=A Seminar on the session description protocol\r\n" "u=http://www.cs.ucl.ac.uk/staff/M.Handley/sdp.03.ps\r\n" "[email protected] (Mark Handley)\r\n" "c=IN IP4 224.2.17.12/127\r\n" "t=2873397496 2873404696\r\n" "m=audio 49170 RTP/AVP 0\r\n" // media description 0 "c=IN IP4 224.2.17.12/127\r\n" "a=recvonly\r\n" "m=video 51372 RTP/AVP 31\r\n" // media description 1 "a=inactive\r\n" "m=application 32416 udp wb\r\n" // media description 2 "a=sendonly\r\n" "m=audio 55554 RTP/AVP 0\r\n" // media description 3 "c=IN IP4 224.2.17.12/127\r\n" "a=sendrecv\r\n" "m=audio 55560 RTP/AVP 0\r\n" // media description 4 ; SdpBody body(sdp); MediaDescriptor md0( body, 0, CALLER ); MediaDescriptor md1( body, 1, CALLER ); MediaDescriptor md2( body, 2, CALLER ); MediaDescriptor md3( body, 3, CALLER ); MediaDescriptor md4( body, 4, CALLER ); CPPUNIT_ASSERT( md0.getType() == "audio" ); CPPUNIT_ASSERT( md0.getDirectionality() == RECV_ONLY ); CPPUNIT_ASSERT( md0.getDirectionalityOverride() == NOT_A_DIRECTION ); md0.setDirectionalityOverride( INACTIVE ); CPPUNIT_ASSERT( md0.getDirectionalityOverride() == INACTIVE ); CPPUNIT_ASSERT( md1.getType() == "video" ); CPPUNIT_ASSERT( md1.getDirectionality() == INACTIVE ); CPPUNIT_ASSERT( md2.getType() == "application" ); CPPUNIT_ASSERT( md2.getDirectionality() == SEND_ONLY ); CPPUNIT_ASSERT( md3.getType() == "audio" ); CPPUNIT_ASSERT( md3.getDirectionality() == SEND_RECV ); CPPUNIT_ASSERT( md4.getType() == "audio" ); CPPUNIT_ASSERT( md4.getDirectionality() == SEND_RECV ); }
static void md3(char ***tip, int n_units, int ndim, int *dims) { int i; for(i=1; i<n_units; i++) { if(ndim == 1) /* final dimension - must scale by element width */ tip[i] = (char **)((char *)tip[0] + i*dims[0]*w_units); else /* intermediate dimension - scale by pointer size */ tip[i] = tip[0] + i*dims[0]; } if(ndim > 1) /* not at final dimension - continue to recurse */ md3((char ***)tip[0], n_units*dims[0], ndim-1, &dims[1]); }
// ***************************************************************************** // Main int main(int argc, char* const argv[]) { try { if (argc != 2) { std::cout << "Usage: " << argv[0] << " file\n"; return 1; } std::string file(argv[1]); std::cout <<"----- One IFD0 tag\n"; Exiv2::ExifData ed1; Exiv2::Exifdatum md1(Exiv2::ExifKey("Exif.Image.Model")); md1.setValue("Test 1"); ed1.add(md1); write(file, ed1); print(file); std::cout <<"\n----- One Exif tag\n"; Exiv2::ExifData ed2; Exiv2::Exifdatum md2(Exiv2::ExifKey("Exif.Photo.DateTimeOriginal")); md2.setValue("Test 2"); ed2.add(md2); write(file, ed2); print(file); // Todo: One Makernote tag for each Makernote std::cout <<"\n----- One IOP tag\n"; Exiv2::ExifData ed3; Exiv2::Exifdatum md3(Exiv2::ExifKey("Exif.Iop.InteroperabilityVersion")); md3.setValue("Test 3"); ed3.add(md3); write(file, ed3); print(file); std::cout <<"\n----- One GPS tag\n"; Exiv2::ExifData ed4; Exiv2::Exifdatum md4(Exiv2::ExifKey("Exif.GPSInfo.GPSVersionID")); md4.setValue("Test 4"); ed4.add(md4); write(file, ed4); print(file); // Todo: Fix this std::cout <<"\n----- One IFD1 tag\n"; Exiv2::ExifData ed5; Exiv2::Exifdatum md5(Exiv2::ExifKey("Exif.Thumbnail.Artist")); md5.setValue("Test 5"); ed5.add(md5); Exiv2::Exifdatum md6(Exiv2::ExifKey("Exif.Image.Model")); md6.setValue("Test 5 (Fix me!)"); ed5.add(md6); write(file, ed5); print(file); return 0; } catch (Exiv2::Error& e) { std::cout << "Caught Exiv2 exception '" << e << "'\n"; return -1; } }
void testMediaDescriptor_GetEndpointData() { const char *sdpOffer = "v=0\r\n" "o=mhandley 2890844526 2890842807 IN IP4 126.16.64.4\r\n" "s=SDP Seminar\r\n" "i=A Seminar on the session description protocol\r\n" "u=http://www.cs.ucl.ac.uk/staff/M.Handley/sdp.03.ps\r\n" "[email protected] (Mark Handley)\r\n" "c=IN IP4 10.10.10.1\r\n" "t=2873397496 2873404696\r\n" "m=audio 10000 RTP/AVP 0\r\n" // media description 0 "c=IN IP4 10.10.10.2\r\n" "a=recvonly\r\n" "m=video 10002 RTP/AVP 31\r\n" // media description 1 "a=inactive\r\n" "m=application 10004 udp wb\r\n" // media description 2 "a=sendonly\r\n" "m=audio 10006 RTP/AVP 0\r\n" // media description 3 "c=IN IP4 10.10.10.3\r\n" "a=sendrecv\r\n" "m=audio 10008 RTP/AVP 0\r\n" // media description 4 ; SdpBody offerBody(sdpOffer); const char *sdpAnswer = "v=0\r\n" "o=mhandley 2890844526 2890842807 IN IP4 126.16.64.4\r\n" "s=SDP Seminar\r\n" "i=A Seminar on the session description protocol\r\n" "u=http://www.cs.ucl.ac.uk/staff/M.Handley/sdp.03.ps\r\n" "[email protected] (Mark Handley)\r\n" "c=IN IP4 20.10.10.1\r\n" "t=2873397496 2873404696\r\n" "m=audio 20000 RTP/AVP 0\r\n" // media description 0 "c=IN IP4 20.10.10.2\r\n" "a=recvonly\r\n" "m=video 20002 RTP/AVP 31\r\n" // media description 1 "a=inactive\r\n" "m=application 20004 udp wb\r\n" // media description 2 "a=sendonly\r\n" "m=audio 20006 RTP/AVP 0\r\n" // media description 3 "c=IN IP4 20.10.10.3\r\n" "a=sendrecv\r\n" "m=audio 20008 RTP/AVP 0\r\n" // media description 4 ; SdpBody answerBody(sdpAnswer); MediaDescriptor md0( offerBody, 0, CALLER ); MediaDescriptor md1( offerBody, 1, CALLER ); MediaDescriptor md2( offerBody, 2, CALLER ); MediaDescriptor md3( offerBody, 3, CALLER ); MediaDescriptor md4( offerBody, 4, CALLER ); md0.setEndpointData( answerBody, 0, CALLEE ); md1.setEndpointData( answerBody, 1, CALLEE ); md2.setEndpointData( answerBody, 2, CALLEE ); md3.setEndpointData( answerBody, 3, CALLEE ); md4.setEndpointData( answerBody, 4, CALLEE ); MediaEndpoint mediaEndpoint; // Media Descriptor 0 mediaEndpoint = md0.getEndpoint( CALLER ); CPPUNIT_ASSERT( mediaEndpoint.getAddress() == "10.10.10.2" ); CPPUNIT_ASSERT( mediaEndpoint.getRtpPort() == 10000 ); CPPUNIT_ASSERT( mediaEndpoint.getRtcpPort() == 10001 ); mediaEndpoint = md0.getEndpoint( CALLEE ); CPPUNIT_ASSERT( mediaEndpoint.getAddress() == "20.10.10.2" ); CPPUNIT_ASSERT( mediaEndpoint.getRtpPort() == 20000 ); CPPUNIT_ASSERT( mediaEndpoint.getRtcpPort() == 20001 ); // Media Descriptor 1 mediaEndpoint = md1.getEndpoint( CALLER ); CPPUNIT_ASSERT( mediaEndpoint.getAddress() == "10.10.10.1" ); CPPUNIT_ASSERT( mediaEndpoint.getRtpPort() == 10002 ); CPPUNIT_ASSERT( mediaEndpoint.getRtcpPort() == 10003 ); mediaEndpoint = md1.getEndpoint( CALLEE ); CPPUNIT_ASSERT( mediaEndpoint.getAddress() == "20.10.10.1" ); CPPUNIT_ASSERT( mediaEndpoint.getRtpPort() == 20002 ); CPPUNIT_ASSERT( mediaEndpoint.getRtcpPort() == 20003 ); // Media Descriptor 2 mediaEndpoint = md2.getEndpoint( CALLER ); CPPUNIT_ASSERT( mediaEndpoint.getAddress() == "10.10.10.1" ); CPPUNIT_ASSERT( mediaEndpoint.getRtpPort() == 10004 ); CPPUNIT_ASSERT( mediaEndpoint.getRtcpPort() == 10005 ); mediaEndpoint = md2.getEndpoint( CALLEE ); CPPUNIT_ASSERT( mediaEndpoint.getAddress() == "20.10.10.1" ); CPPUNIT_ASSERT( mediaEndpoint.getRtpPort() == 20004 ); CPPUNIT_ASSERT( mediaEndpoint.getRtcpPort() == 20005 ); // Media Descriptor 3 mediaEndpoint = md3.getEndpoint( CALLER ); CPPUNIT_ASSERT( mediaEndpoint.getAddress() == "10.10.10.3" ); CPPUNIT_ASSERT( mediaEndpoint.getRtpPort() == 10006 ); CPPUNIT_ASSERT( mediaEndpoint.getRtcpPort() == 10007 ); mediaEndpoint = md3.getEndpoint( CALLEE ); CPPUNIT_ASSERT( mediaEndpoint.getAddress() == "20.10.10.3" ); CPPUNIT_ASSERT( mediaEndpoint.getRtpPort() == 20006 ); CPPUNIT_ASSERT( mediaEndpoint.getRtcpPort() == 20007 ); // Media Descriptor 4 mediaEndpoint = md4.getEndpoint( CALLER ); CPPUNIT_ASSERT( mediaEndpoint.getAddress() == "10.10.10.1" ); CPPUNIT_ASSERT( mediaEndpoint.getRtpPort() == 10008 ); CPPUNIT_ASSERT( mediaEndpoint.getRtcpPort() == 10009 ); mediaEndpoint = md4.getEndpoint( CALLEE ); CPPUNIT_ASSERT( mediaEndpoint.getAddress() == "20.10.10.1" ); CPPUNIT_ASSERT( mediaEndpoint.getRtpPort() == 20008 ); CPPUNIT_ASSERT( mediaEndpoint.getRtcpPort() == 20009 ); }