2 * Copyright (c) 2004-2007 Marcus Overhagen <marcus@overhagen.de>
4 * Permission is hereby granted, free of charge, to any person
5 * obtaining a copy of this software and associated documentation
6 * files (the "Software"), to deal in the Software without restriction,
7 * including without limitation the rights to use, copy, modify,
8 * merge, publish, distribute, sublicense, and/or sell copies of
9 * the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
25 #include "DeviceRoster.h"
32 DeviceRoster
*gDeviceRoster
;
36 DeviceRoster::DeviceRoster()
38 live_node_info info
[MAX_DEVICE_COUNT
];
39 int32 info_count
= MAX_DEVICE_COUNT
;
41 err
= MediaRoster()->GetLiveNodes(info
, &info_count
, NULL
, NULL
, "DVB*",
42 B_BUFFER_PRODUCER
| B_PHYSICAL_INPUT
);
43 if (err
!= B_OK
|| info_count
< 1) {
44 printf("Can't find live DVB node. Found %" B_PRId32
" nodes, error %08" B_PRIx32
" (%s)\n",
45 info_count
, err
, strerror(err
));
48 fDeviceCount
= info_count
;
49 for (int i
= 0; i
< fDeviceCount
; i
++) {
50 fDeviceInfo
[i
].node
= info
[i
].node
;
51 strcpy(fDeviceInfo
[i
].name
, info
[i
].name
);
57 DeviceRoster::~DeviceRoster()
63 DeviceRoster::DeviceCount()
70 DeviceRoster::DeviceName(int i
)
72 ASSERT(i
>= 0 && i
< fDeviceCount
);
73 return fDeviceInfo
[i
].name
;
78 DeviceRoster::DeviceNode(int i
)
80 ASSERT(i
>= 0 && i
< fDeviceCount
);
81 return fDeviceInfo
[i
].node
;
86 DeviceRoster::IsRawAudioOutputFree(int i
)
88 ASSERT(i
>= 0 && i
< fDeviceCount
);
94 err
= MediaRoster()->GetFreeOutputsFor(fDeviceInfo
[i
].node
, &output
, 1,
95 &count
, B_MEDIA_RAW_AUDIO
);
96 return (err
== B_OK
) && (count
== 1);
101 DeviceRoster::IsEncAudioOutputFree(int i
)
103 ASSERT(i
>= 0 && i
< fDeviceCount
);
109 err
= MediaRoster()->GetFreeOutputsFor(fDeviceInfo
[i
].node
, &output
, 1,
110 &count
, B_MEDIA_ENCODED_AUDIO
);
111 return (err
== B_OK
) && (count
== 1);
116 DeviceRoster::IsRawVideoOutputFree(int i
)
118 ASSERT(i
>= 0 && i
< fDeviceCount
);
124 err
= MediaRoster()->GetFreeOutputsFor(fDeviceInfo
[i
].node
, &output
, 1,
125 &count
, B_MEDIA_RAW_VIDEO
);
126 return (err
== B_OK
) && (count
== 1);
131 DeviceRoster::IsEncVideoOutputFree(int i
)
133 ASSERT(i
>= 0 && i
< fDeviceCount
);
139 err
= MediaRoster()->GetFreeOutputsFor(fDeviceInfo
[i
].node
, &output
, 1,
140 &count
, B_MEDIA_ENCODED_VIDEO
);
141 return (err
== B_OK
) && (count
== 1);
146 DeviceRoster::MediaRoster()
148 return BMediaRoster::Roster();