root/trunk/freebob/src/avnameinfoblock.cpp

Revision 22, 2.5 kB (checked in by pieterpalmers, 19 years ago)

- Added the following info block handlers:

Basic read functionallity only.

- Changed Makefile.am to reflect these new files
- Removed a bug from avdescriptor->readBuffer
- Added some basic tests of the new handlers (remark: the new tests could be device specific)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 /* avnameinfoblock.cpp
2  * Copyright (C) 2004 by Pieter Palmers
3  *
4  * This file is part of FreeBob.
5  *
6  * FreeBob 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.
10  * FreeBob 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.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with FreeBob; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
18  * MA 02111-1307 USA.
19  */
20
21
22 #include <string.h>
23 #include <errno.h>
24 #include <libavc1394/avc1394.h>
25 #include <libavc1394/avc1394_vcr.h>
26 #include "debugmodule.h"
27
28 #include "avdescriptor.h"
29 #include "avinfoblock.h"
30 #include "avnameinfoblock.h"
31
32 AvNameInfoBlock::AvNameInfoBlock(AvDescriptor *parent, int address) : AvInfoBlock(parent,address) {
33         // do some more valid checks
34         if (getType() != 0x000B) {
35                 bValid=false;
36         }       
37         nameBuffer=NULL;
38
39 }
40
41 AvNameInfoBlock::~AvNameInfoBlock() {
42
43         if(nameBuffer) {
44                 delete nameBuffer;
45         }
46 }
47
48 unsigned char * AvNameInfoBlock::getName() {
49
50         // PP: Can't find this in the specs I have... going to look around a bit for the spec this is in.
51         //     (AV/C Information Block Types Specification Version 1.0)
52         unsigned int namelen;
53         unsigned int readlen=0;
54         if (isValid()) {
55                 // PP: we should parse some raw_text_info_blocks here, but the music spec indicates that there are maximum 3 of these
56                 //     so I do it manually here.
57                 // PP: for my device apparently one block is sufficient.
58                 // PP: one strange thing remains, that is that there are some NULL characters in the buffer.
59                 unsigned int length_of_textblock_1=readWord(0x0A);
60                 unsigned int type_of_textblock_1=readWord(0x0C); // = 0x000A ?
61                 unsigned int primary_field_length_textblock_1=readWord(0x0E); // ?? I guess ??
62                
63                 if (nameBuffer) {
64                         delete nameBuffer;
65                 }
66                 nameBuffer=new unsigned char[primary_field_length_textblock_1];
67                
68                 if((readlen=readBuffer(0x10,primary_field_length_textblock_1,nameBuffer))<primary_field_length_textblock_1) {
69                         debugPrint (DEBUG_LEVEL_INFO, "      truncated????\n");
70                        
71                         nameBuffer[primary_field_length_textblock_1-1]=0; // make sure the string converter doesn't read past the buffer
72                 }
73                
74                 return nameBuffer;
75         } else {
76                 return NULL;
77         }
78 }
Note: See TracBrowser for help on using the browser.