1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635
|
/*****************************************************************************
* open.m: Open dialogues for VLC's MacOS X port
*****************************************************************************
* Copyright (C) 2002-2012 VLC authors and VideoLAN
* $Id: 46a51908de7e38d6e312654871639a7cac35155d $
*
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
* Christophe Massiot <massiot@via.ecp.fr>
* Derk-Jan Hartman <thedj@users.sourceforge.net>
* Benjamin Pracht <bigben at videolan dot org>
* Felix Paul Kühne <fkuehne at videolan dot org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#import <stdlib.h> /* malloc(), free() */
#import <sys/param.h> /* for MAXPATHLEN */
#import "CompatibilityFixes.h"
#import <paths.h>
#import <IOKit/IOBSD.h>
#import <IOKit/storage/IOMedia.h>
#import <IOKit/storage/IOCDMedia.h>
#import <IOKit/storage/IODVDMedia.h>
#import <IOKit/storage/IOBDMedia.h>
#import <Cocoa/Cocoa.h>
#import <QTKit/QTKit.h>
#import "intf.h"
#import "playlist.h"
#import "open.h"
#import "output.h"
#import "eyetv.h"
#import "misc.h"
#import <vlc_url.h>
NSArray *qtkvideoDevices;
NSArray *qtkaudioDevices;
#define setEyeTVUnconnected \
[o_capture_lbl setStringValue: _NS("No device is selected")]; \
[o_capture_long_lbl setStringValue: _NS("No device is selected.\n\nChoose available device in above pull-down menu.\n")]; \
[o_capture_lbl displayIfNeeded]; \
[o_capture_long_lbl displayIfNeeded]; \
[self showCaptureView: o_capture_label_view]
struct display_info_t
{
CGRect rect;
CGDirectDisplayID id;
};
/*****************************************************************************
* VLCOpen implementation
*****************************************************************************/
@implementation VLCOpen
@synthesize fileSubDelay, fileSubFps;
#pragma mark -
#pragma mark Init
static VLCOpen *_o_sharedMainInstance = nil;
+ (VLCOpen *)sharedInstance
{
return _o_sharedMainInstance ? _o_sharedMainInstance : [[self alloc] init];
}
- (id)init
{
if (_o_sharedMainInstance)
[self dealloc];
else
_o_sharedMainInstance = [super init];
return _o_sharedMainInstance;
}
- (void)dealloc
{
[o_allMediaDevices release];
[o_specialMediaFolders release];
if (o_opticalDevices)
[o_opticalDevices release];
if (o_file_slave_path)
[o_file_slave_path release];
[o_mrl release];
if (o_sub_path)
[o_sub_path release];
[o_currentOpticalMediaIconView release];
[o_currentOpticalMediaView release];
for (int i = 0; i < [o_displayInfos count]; i ++) {
NSValue *v = [o_displayInfos objectAtIndex:i];
free([v pointerValue]);
}
[o_displayInfos removeAllObjects];
[o_displayInfos release];
[super dealloc];
}
- (void)awakeFromNib
{
if (!OSX_SNOW_LEOPARD)
[o_panel setCollectionBehavior: NSWindowCollectionBehaviorFullScreenAuxiliary];
[o_panel setTitle: _NS("Open Source")];
[o_mrl_lbl setStringValue: _NS("Media Resource Locator (MRL)")];
[o_btn_ok setTitle: _NS("Open")];
[o_btn_cancel setTitle: _NS("Cancel")];
[[o_tabview tabViewItemAtIndex: 0] setLabel: _NS("File")];
[o_tabview accessibilitySetOverrideValue:_NS("4 Tabs to choose between media input. Select 'File' for files, 'Disc' for optical media such as DVDs, Audio CDs or BRs, 'Network' for network streams or 'Capture' for Input Devices such as microphones or cameras, the current screen or TV streams if the EyeTV application is installed.") forAttribute:NSAccessibilityDescriptionAttribute];
[[o_tabview tabViewItemAtIndex: 1] setLabel: _NS("Disc")];
[[o_tabview tabViewItemAtIndex: 2] setLabel: _NS("Network")];
[[o_tabview tabViewItemAtIndex: 3] setLabel: _NS("Capture")];
[o_file_name setStringValue: @""];
[o_file_name_stub setStringValue: _NS("Choose a file")];
[o_file_icon_well setImage: [NSImage imageNamed:@"generic"]];
[o_file_btn_browse setTitle: _NS("Browse...")];
[[o_file_btn_browse cell] accessibilitySetOverrideValue:_NS("Click to select a file for playback") forAttribute:NSAccessibilityDescriptionAttribute];
[o_file_stream setTitle: _NS("Treat as a pipe rather than as a file")];
[o_file_stream setHidden: NO];
[o_file_slave_ckbox setTitle: _NS("Play another media synchronously")];
[o_file_slave_select_btn setTitle: _NS("Choose...")];
[[o_file_btn_browse cell] accessibilitySetOverrideValue:_NS("Click to select a another file to play it in sync with the previously selected file.") forAttribute:NSAccessibilityDescriptionAttribute];
[o_file_slave_filename_lbl setStringValue: @""];
[o_file_slave_icon_well setImage: NULL];
[o_file_subtitles_filename_lbl setStringValue: @""];
[o_file_subtitles_icon_well setImage: NULL];
[o_file_custom_timing_ckb setTitle: _NS("Custom playback")];
[o_file_starttime_lbl setStringValue: _NS("Start time")];
[o_file_starttime_fld setStringValue: @""];
[o_file_stoptime_lbl setStringValue: _NS("Stop time")];
[o_file_stoptime_fld setStringValue: @""];
[o_disc_selector_pop removeAllItems];
[o_disc_selector_pop setHidden: NO];
NSString *o_videots = _NS("Open VIDEO_TS / BDMV folder");
[o_disc_nodisc_lbl setStringValue: _NS("Insert Disc")];
[o_disc_nodisc_videots_btn setTitle: o_videots];
[o_disc_audiocd_lbl setStringValue: _NS("Audio CD")];
[o_disc_audiocd_trackcount_lbl setStringValue: @""];
[o_disc_audiocd_videots_btn setTitle: o_videots];
[o_disc_dvd_lbl setStringValue: @""];
[o_disc_dvd_disablemenus_btn setTitle: _NS("Disable DVD menus")];
[o_disc_dvd_videots_btn setTitle: o_videots];
[o_disc_dvdwomenus_lbl setStringValue: @""];
[o_disc_dvdwomenus_enablemenus_btn setTitle: _NS("Enable DVD menus")];
[o_disc_dvdwomenus_videots_btn setTitle: o_videots];
[o_disc_dvdwomenus_title_lbl setStringValue: _NS("Title")];
[o_disc_dvdwomenus_chapter_lbl setStringValue: _NS("Chapter")];
[o_disc_vcd_title_lbl setStringValue: _NS("Title")];
[o_disc_vcd_chapter_lbl setStringValue: _NS("Chapter")];
[o_disc_vcd_videots_btn setTitle: o_videots];
[o_disc_bd_videots_btn setTitle: o_videots];
[o_net_udp_port_lbl setStringValue: _NS("Port")];
[o_net_udpm_addr_lbl setStringValue: _NS("IP Address")];
[o_net_udpm_port_lbl setStringValue: _NS("Port")];
[o_net_http_url_lbl setStringValue: _NS("URL")];
[o_net_help_lbl setStringValue: _NS("To Open a usual network stream (HTTP, RTSP, RTMP, MMS, FTP, etc.), just enter the URL in the field above. If you want to open a RTP or UDP stream, press the button below.")];
[o_net_help_udp_lbl setStringValue: _NS("If you want to open a multicast stream, enter the respective IP address given by the stream provider. In unicast mode, VLC will use your machine's IP automatically.\n\nTo open a stream using a different protocol, just press Cancel to close this sheet.")];
[[o_net_http_url cell] accessibilitySetOverrideValue:_NS("Enter a URL here to open the network stream. To open RTP or UDP streams, click on the respective button below.") forAttribute:NSAccessibilityDescriptionAttribute];
[o_net_udp_cancel_btn setTitle: _NS("Cancel")];
[o_net_udp_ok_btn setTitle: _NS("Open")];
[o_net_openUDP_btn setTitle: _NS("Open RTP/UDP Stream")];
[o_net_udp_mode_lbl setStringValue: _NS("Mode")];
[o_net_udp_protocol_lbl setStringValue: _NS("Protocol")];
[o_net_udp_address_lbl setStringValue: _NS("Address")];
[[o_net_mode cellAtRow:0 column:0] setTitle: _NS("Unicast")];
[[o_net_mode cellAtRow:1 column:0] setTitle: _NS("Multicast")];
[o_net_udp_port setIntValue: config_GetInt(VLCIntf, "server-port")];
[o_net_udp_port_stp setIntValue: config_GetInt(VLCIntf, "server-port")];
[o_eyetv_chn_bgbar setUsesThreadedAnimation: YES];
[o_capture_mode_pop removeAllItems];
[o_capture_mode_pop addItemWithTitle: _NS("Input Devices")];
[o_capture_mode_pop addItemWithTitle: _NS("Screen")];
[o_capture_mode_pop addItemWithTitle: @"EyeTV"];
[o_screen_long_lbl setStringValue: _NS("This input allows you to save, stream or display your current screen contents.")];
[o_screen_fps_lbl setStringValue: [NSString stringWithFormat:@"%@:",_NS("Frames per Second")]];
[o_screen_screen_lbl setStringValue: [NSString stringWithFormat:@"%@:",_NS("Screen")]];
[o_screen_left_lbl setStringValue: [NSString stringWithFormat:@"%@:",_NS("Subscreen left")]];
[o_screen_top_lbl setStringValue: [NSString stringWithFormat:@"%@:",_NS("Subscreen top")]];
[o_screen_width_lbl setStringValue: [NSString stringWithFormat:@"%@:",_NS("Subscreen width")]];
[o_screen_height_lbl setStringValue: [NSString stringWithFormat:@"%@:",_NS("Subscreen height")]];
[o_screen_follow_mouse_ckb setTitle: _NS("Follow the mouse")];
[o_screen_qtk_audio_ckb setTitle: _NS("Capture Audio")];
[o_eyetv_currentChannel_lbl setStringValue: _NS("Current channel:")];
[o_eyetv_previousProgram_btn setTitle: _NS("Previous Channel")];
[o_eyetv_nextProgram_btn setTitle: _NS("Next Channel")];
[o_eyetv_chn_status_txt setStringValue: _NS("Retrieving Channel Info...")];
[o_eyetv_noInstance_lbl setStringValue: _NS("EyeTV is not launched")];
[o_eyetv_noInstanceLong_lbl setStringValue: _NS("VLC could not connect to EyeTV.\nMake sure that you installed VLC's EyeTV plugin.")];
[o_eyetv_launchEyeTV_btn setTitle: _NS("Launch EyeTV now")];
[o_eyetv_getPlugin_btn setTitle: _NS("Download Plugin")];
[o_capture_width_lbl setStringValue: [NSString stringWithFormat:@"%@:",_NS("Image width")]];
[o_capture_height_lbl setStringValue: [NSString stringWithFormat:@"%@:",_NS("Image height")]];
// setup start / stop time fields
[o_file_starttime_fld setFormatter:[[[PositionFormatter alloc] init] autorelease]];
[o_file_stoptime_fld setFormatter:[[[PositionFormatter alloc] init] autorelease]];
[self qtkvideoDevices];
[o_qtk_video_device_pop removeAllItems];
msg_Dbg(VLCIntf, "Found %lu video capture devices", [qtkvideoDevices count]);
if ([qtkvideoDevices count] >= 1) {
if (!qtk_currdevice_uid)
qtk_currdevice_uid = [[[QTCaptureDevice defaultInputDeviceWithMediaType: QTMediaTypeVideo] uniqueID]
stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
NSUInteger deviceCount = [qtkvideoDevices count];
for (int ivideo = 0; ivideo < deviceCount; ivideo++) {
QTCaptureDevice *qtk_device;
qtk_device = [qtkvideoDevices objectAtIndex:ivideo];
// allow same name for multiple times
[[o_qtk_video_device_pop menu] addItemWithTitle:[qtk_device localizedDisplayName] action:nil keyEquivalent:@""];
if ([[[qtk_device uniqueID] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] isEqualToString:qtk_currdevice_uid])
[o_qtk_video_device_pop selectItemAtIndex:ivideo];
}
} else {
[o_qtk_video_device_pop addItemWithTitle: _NS("None")];
[qtk_currdevice_uid release];
}
[self qtkaudioDevices];
[o_qtk_audio_device_pop removeAllItems];
[o_screen_qtk_audio_pop removeAllItems];
msg_Dbg(VLCIntf, "Found %lu audio capture devices", [qtkaudioDevices count]);
if ([qtkaudioDevices count] >= 1) {
if (!qtkaudio_currdevice_uid)
qtkaudio_currdevice_uid = [[[QTCaptureDevice defaultInputDeviceWithMediaType: QTMediaTypeSound] uniqueID]
stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
NSUInteger deviceCount = [qtkaudioDevices count];
for (int iaudio = 0; iaudio < deviceCount; iaudio++) {
QTCaptureDevice *qtkaudio_device = [qtkaudioDevices objectAtIndex:iaudio];
// allow same name for multiple times
[[o_qtk_audio_device_pop menu] addItemWithTitle:[qtkaudio_device localizedDisplayName] action:nil keyEquivalent:@""];
[[o_screen_qtk_audio_pop menu] addItemWithTitle:[qtkaudio_device localizedDisplayName] action:nil keyEquivalent:@""];
if ([[[qtkaudio_device uniqueID] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] isEqualToString:qtkaudio_currdevice_uid]) {
[o_qtk_audio_device_pop selectItemAtIndex:iaudio];
[o_screen_qtk_audio_pop selectItemAtIndex:iaudio];
}
}
} else {
[o_qtk_audio_device_pop addItemWithTitle: _NS("None")];
[o_screen_qtk_audio_pop addItemWithTitle: _NS("None")];
[qtkaudio_currdevice_uid release];
}
[self setSubPanel];
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(openNetInfoChanged:)
name: NSControlTextDidChangeNotification
object: o_net_udp_port];
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(openNetInfoChanged:)
name: NSControlTextDidChangeNotification
object: o_net_udpm_addr];
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(openNetInfoChanged:)
name: NSControlTextDidChangeNotification
object: o_net_udpm_port];
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(openNetInfoChanged:)
name: NSControlTextDidChangeNotification
object: o_net_http_url];
[[NSDistributedNotificationCenter defaultCenter] addObserver: self
selector: @selector(eyetvChanged:)
name: NULL
object: @"VLCEyeTVSupport"
suspensionBehavior: NSNotificationSuspensionBehaviorDeliverImmediately];
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(screenFPSfieldChanged:)
name: NSControlTextDidChangeNotification
object: o_screen_fps_fld];
/* register clicks on text fields */
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(textFieldWasClicked:)
name: @"VLCOpenTextFieldWasClicked"
object: nil];
/* we want to be notified about removed or added media */
o_allMediaDevices = [[NSMutableArray alloc] init];
o_specialMediaFolders = [[NSMutableArray alloc] init];
o_displayInfos = [[NSMutableArray alloc] init];
NSWorkspace *sharedWorkspace = [NSWorkspace sharedWorkspace];
[[sharedWorkspace notificationCenter] addObserver:self selector:@selector(scanOpticalMedia:) name:NSWorkspaceDidMountNotification object:nil];
[[sharedWorkspace notificationCenter] addObserver:self selector:@selector(scanOpticalMedia:) name:NSWorkspaceDidUnmountNotification object:nil];
[self qtkToggleUIElements:nil];
[self scanOpticalMedia:nil];
[self setMRL: @""];
}
- (void)setMRL:(NSString *)newMRL
{
if (!newMRL)
newMRL = @"";
if (o_mrl)
[o_mrl release];
o_mrl = newMRL;
[o_mrl retain];
[o_mrl_fld performSelectorOnMainThread:@selector(setStringValue:) withObject:o_mrl waitUntilDone:NO];
if ([o_mrl length] > 0)
[o_btn_ok setEnabled: YES];
else
[o_btn_ok setEnabled: NO];
}
- (NSString *)MRL
{
return o_mrl;
}
- (void)setSubPanel
{
int i_index;
module_config_t * p_item;
intf_thread_t * p_intf = VLCIntf;
[o_file_sub_ckbox setTitle: _NS("Add Subtitle File:")];
[o_file_sub_path_lbl setStringValue: _NS("Choose a file")];
[o_file_sub_path_lbl setHidden: NO];
[o_file_sub_path_fld setStringValue: @""];
[o_file_sub_btn_settings setTitle: _NS("Choose...")];
[[o_file_btn_browse cell] accessibilitySetOverrideValue:_NS("Click to setup subtitle playback in full detail.") forAttribute:NSAccessibilityDescriptionAttribute];
[o_file_sub_btn_browse setTitle: _NS("Browse...")];
[[o_file_sub_btn_browse cell] accessibilitySetOverrideValue:_NS("Click to select a subtitle file.") forAttribute:NSAccessibilityDescriptionAttribute];
[o_file_sub_override setTitle: _NS("Override parameters")];
[o_file_sub_delay_lbl setStringValue: _NS("Delay")];
[o_file_sub_delay_stp setEnabled: NO];
[o_file_sub_fps_lbl setStringValue: _NS("FPS")];
[o_file_sub_fps_stp setEnabled: NO];
[o_file_sub_encoding_lbl setStringValue: _NS("Subtitle encoding")];
[o_file_sub_encoding_pop removeAllItems];
[o_file_sub_size_lbl setStringValue: _NS("Font size")];
[o_file_sub_size_pop removeAllItems];
[o_file_sub_align_lbl setStringValue: _NS("Subtitle alignment")];
[o_file_sub_align_pop removeAllItems];
[o_file_sub_ok_btn setStringValue: _NS("OK")];
[[o_file_sub_ok_btn cell] accessibilitySetOverrideValue:_NS("Click to dismiss the subtitle setup dialog.") forAttribute:NSAccessibilityDescriptionAttribute];
[o_file_sub_font_box setTitle: _NS("Font Properties")];
[o_file_sub_file_box setTitle: _NS("Subtitle File")];
p_item = config_FindConfig(VLC_OBJECT(p_intf), "subsdec-encoding");
if (p_item) {
for (int i = 0; i < p_item->list_count; i++) {
[o_file_sub_encoding_pop addItemWithTitle: _NS(p_item->list_text[i])];
[[o_file_sub_encoding_pop lastItem] setRepresentedObject:[NSString stringWithFormat:@"%s", p_item->list.psz[i]]];
if (p_item->value.psz && !strcmp(p_item->value.psz, p_item->list.psz[i]))
[o_file_sub_encoding_pop selectItem: [o_file_sub_encoding_pop lastItem]];
}
if ([o_file_sub_encoding_pop indexOfSelectedItem] < 0)
[o_file_sub_encoding_pop selectItemAtIndex:0];
}
p_item = config_FindConfig(VLC_OBJECT(p_intf), "subsdec-align");
if (p_item) {
for (i_index = 0; i_index < p_item->list_count; i_index++)
[o_file_sub_align_pop addItemWithTitle: _NS(p_item->list_text[i_index])];
[o_file_sub_align_pop selectItemAtIndex: p_item->value.i];
}
p_item = config_FindConfig(VLC_OBJECT(p_intf), "freetype-rel-fontsize");
if (p_item) {
for (i_index = 0; i_index < p_item->list_count; i_index++) {
[o_file_sub_size_pop addItemWithTitle: _NS(p_item->list_text[i_index])];
if (p_item->value.i == p_item->list.i[i_index])
[o_file_sub_size_pop selectItemAtIndex: i_index];
}
}
}
- (void)openTarget:(int)i_type
{
/* check whether we already run a modal dialog */
if ([NSApp modalWindow] != nil)
return;
int i_result;
b_autoplay = config_GetInt(VLCIntf, "macosx-autoplay");
[o_tabview selectTabViewItemAtIndex: i_type];
[o_file_sub_ckbox setState: NSOffState];
i_result = [NSApp runModalForWindow: o_panel];
[o_panel close];
if (i_result) {
NSMutableDictionary *o_dic;
NSMutableArray *o_options = [NSMutableArray array];
o_dic = [NSMutableDictionary dictionaryWithObject: [self MRL] forKey: @"ITEM_URL"];
if ([o_file_sub_ckbox state] == NSOnState) {
module_config_t * p_item;
[o_options addObject: [NSString stringWithFormat: @"sub-file=%@", o_sub_path]];
if ([o_file_sub_override state] == NSOnState) {
[o_options addObject: [NSString stringWithFormat: @"sub-delay=%f", ([self fileSubDelay] * 10)]];
[o_options addObject: [NSString stringWithFormat: @"sub-fps=%f", [self fileSubFps]]];
}
[o_options addObject: [NSString stringWithFormat:
@"subsdec-encoding=%@", [[o_file_sub_encoding_pop selectedItem] representedObject]]];
[o_options addObject: [NSString stringWithFormat:
@"subsdec-align=%li", [o_file_sub_align_pop indexOfSelectedItem]]];
p_item = config_FindConfig(VLC_OBJECT(VLCIntf),
"freetype-rel-fontsize");
if (p_item) {
[o_options addObject: [NSString stringWithFormat:
@"freetype-rel-fontsize=%i",
p_item->list.i[[o_file_sub_size_pop indexOfSelectedItem]]]];
}
}
if ([o_file_custom_timing_ckb state] == NSOnState) {
NSArray * components = [[o_file_starttime_fld stringValue] componentsSeparatedByString:@":"];
NSUInteger componentCount = [components count];
NSInteger tempValue = 0;
if (componentCount == 1)
tempValue = [[components objectAtIndex:0] intValue];
else if (componentCount == 2)
tempValue = [[components objectAtIndex:0] intValue] * 60 + [[components objectAtIndex:1] intValue];
else if (componentCount == 3)
tempValue = [[components objectAtIndex:0] intValue] * 3600 + [[components objectAtIndex:1] intValue] * 60 + [[components objectAtIndex:2] intValue];
if (tempValue > 0)
[o_options addObject: [NSString stringWithFormat:@"start-time=%li", tempValue]];
components = [[o_file_stoptime_fld stringValue] componentsSeparatedByString:@":"];
componentCount = [components count];
if (componentCount == 1)
tempValue = [[components objectAtIndex:0] intValue];
else if (componentCount == 2)
tempValue = [[components objectAtIndex:0] intValue] * 60 + [[components objectAtIndex:1] intValue];
else if (componentCount == 3)
tempValue = [[components objectAtIndex:0] intValue] * 3600 + [[components objectAtIndex:1] intValue] * 60 + [[components objectAtIndex:2] intValue];
if (tempValue > 0)
[o_options addObject: [NSString stringWithFormat:@"stop-time=%li", tempValue]];
}
if ([o_output_ckbox state] == NSOnState) {
NSArray * soutMRL = [o_sout_options soutMRL];
NSUInteger count = [soutMRL count];
for (NSUInteger i = 0 ; i < count ; i++)
[o_options addObject: [NSString stringWithString: [soutMRL objectAtIndex:i]]];
}
if ([o_file_slave_ckbox state] && o_file_slave_path)
[o_options addObject: [NSString stringWithFormat: @"input-slave=%@", o_file_slave_path]];
if ([[[o_tabview selectedTabViewItem] label] isEqualToString: _NS("Capture")]) {
if ([[[o_capture_mode_pop selectedItem] title] isEqualToString: _NS("Screen")]) {
int selected_index = [o_screen_screen_pop indexOfSelectedItem];
NSValue *v = [o_displayInfos objectAtIndex:selected_index];
struct display_info_t *item = (struct display_info_t *)[v pointerValue];
[o_options addObject: [NSString stringWithFormat: @"screen-fps=%f", [o_screen_fps_fld floatValue]]];
[o_options addObject: [NSString stringWithFormat: @"screen-display-id=%i", item->id]];
[o_options addObject: [NSString stringWithFormat: @"screen-left=%i", [o_screen_left_fld intValue]]];
[o_options addObject: [NSString stringWithFormat: @"screen-top=%i", [o_screen_top_fld intValue]]];
[o_options addObject: [NSString stringWithFormat: @"screen-width=%i", [o_screen_width_fld intValue]]];
[o_options addObject: [NSString stringWithFormat: @"screen-height=%i", [o_screen_height_fld intValue]]];
if ([o_screen_follow_mouse_ckb intValue] == YES)
[o_options addObject: @"screen-follow-mouse"];
else
[o_options addObject: @"no-screen-follow-mouse"];
if ([o_screen_qtk_audio_ckb state] && qtkaudio_currdevice_uid)
[o_options addObject: [NSString stringWithFormat: @"input-slave=qtsound://%@", qtkaudio_currdevice_uid]];
}
else if ([[[o_capture_mode_pop selectedItem] title] isEqualToString: _NS("Input Devices")]) {
if ([o_qtk_video_ckb state]) {
[o_options addObject: [NSString stringWithFormat: @"qtcapture-width=%i", [o_capture_width_fld intValue]]];
[o_options addObject: [NSString stringWithFormat: @"qtcapture-height=%i", [o_capture_height_fld intValue]]];
if ([o_qtk_audio_ckb state] && qtkaudio_currdevice_uid)
[o_options addObject: [NSString stringWithFormat: @"input-slave=qtsound://%@", qtkaudio_currdevice_uid]];
}
}
}
/* apply the options to our item(s) */
[o_dic setObject: (NSArray *)[o_options copy] forKey: @"ITEM_OPTIONS"];
if (b_autoplay)
[[[VLCMain sharedInstance] playlist] appendArray: [NSArray arrayWithObject:o_dic] atPos: -1 enqueue:NO];
else
[[[VLCMain sharedInstance] playlist] appendArray: [NSArray arrayWithObject:o_dic] atPos: -1 enqueue:YES];
}
}
- (IBAction)screenChanged:(id)sender
{
int selected_index = [o_screen_screen_pop indexOfSelectedItem];
if (selected_index >= [o_displayInfos count]) return;
NSValue *v = [o_displayInfos objectAtIndex:selected_index];
struct display_info_t *item = (struct display_info_t *)[v pointerValue];
[o_screen_left_stp setMaxValue: item->rect.size.width];
[o_screen_top_stp setMaxValue: item->rect.size.height];
[o_screen_width_stp setMaxValue: item->rect.size.width];
[o_screen_height_stp setMaxValue: item->rect.size.height];
[o_screen_qtk_audio_pop setEnabled: [o_screen_qtk_audio_ckb state]];
}
- (IBAction)qtkChanged:(id)sender
{
NSInteger i_selectedDevice = [o_qtk_video_device_pop indexOfSelectedItem];
if ([qtkvideoDevices count] >= 1) {
NSValue *sizes = [[[[qtkvideoDevices objectAtIndex:i_selectedDevice] formatDescriptions] objectAtIndex:0] attributeForKey: QTFormatDescriptionVideoEncodedPixelsSizeAttribute];
[o_capture_width_fld setIntValue: [sizes sizeValue].width];
[o_capture_height_fld setIntValue: [sizes sizeValue].height];
[o_capture_width_stp setIntValue: [o_capture_width_fld intValue]];
[o_capture_height_stp setIntValue: [o_capture_height_fld intValue]];
qtk_currdevice_uid = [[(QTCaptureDevice *)[qtkvideoDevices objectAtIndex:i_selectedDevice] uniqueID] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
}
}
- (IBAction)qtkAudioChanged:(id)sender
{
NSInteger i_selectedDevice = [o_qtk_audio_device_pop indexOfSelectedItem];
if ([qtkaudioDevices count] >= 1) {
qtkaudio_currdevice_uid = [[(QTCaptureDevice *)[qtkaudioDevices objectAtIndex:i_selectedDevice] uniqueID] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
}
[o_screen_qtk_audio_pop selectItemAtIndex: i_selectedDevice];
[o_qtk_audio_device_pop selectItemAtIndex: i_selectedDevice];
}
- (IBAction)qtkToggleUIElements:(id)sender
{
[o_qtk_audio_device_pop setEnabled:[o_qtk_audio_ckb state]];
BOOL b_state = [o_qtk_video_ckb state];
[o_qtk_video_device_pop setEnabled:b_state];
[o_capture_width_fld setEnabled:b_state];
[o_capture_width_stp setEnabled:b_state];
[o_capture_height_fld setEnabled:b_state];
[o_capture_height_stp setEnabled:b_state];
[self qtkAudioChanged:sender];
[self qtkChanged:sender];
[self openCaptureModeChanged:sender];
}
#pragma mark -
#pragma mark Main Actions
- (void)tabView:(NSTabView *)o_tv didSelectTabViewItem:(NSTabViewItem *)o_tvi
{
NSString *o_label = [o_tvi label];
if ([o_label isEqualToString: _NS("File")])
[self openFilePathChanged: nil];
else if ([o_label isEqualToString: _NS("Disc")])
[self scanOpticalMedia: nil];
else if ([o_label isEqualToString: _NS("Network")])
[self openNetInfoChanged: nil];
else if ([o_label isEqualToString: _NS("Capture")])
[self openCaptureModeChanged: nil];
}
- (IBAction)expandMRLfieldAction:(id)sender
{
NSRect o_win_rect, o_view_rect;
o_win_rect = [o_panel frame];
o_view_rect = [o_mrl_view frame];
if ([o_mrl_btn state] == NSOffState) {
/* we need to collaps, restore the panel size */
o_win_rect.size.height = o_win_rect.size.height - o_view_rect.size.height;
o_win_rect.origin.y = (o_win_rect.origin.y + o_view_rect.size.height) - o_view_rect.size.height;
/* remove the MRL view */
[o_mrl_view removeFromSuperview];
} else {
/* we need to expand */
[o_mrl_view setFrame: NSMakeRect(0,
[o_mrl_btn frame].origin.y,
o_view_rect.size.width,
o_view_rect.size.height)];
[o_mrl_view setNeedsDisplay: NO];
[o_mrl_view setAutoresizesSubviews: YES];
/* enlarge panel size for MRL view */
o_win_rect.size.height = o_win_rect.size.height + o_view_rect.size.height;
}
[[o_panel animator] setFrame: o_win_rect display:YES];
if ([o_mrl_btn state] == NSOnState)
[[o_panel contentView] addSubview: o_mrl_view];
}
- (void)openFileGeneric
{
[self openFilePathChanged: nil];
[self openTarget: 0];
}
- (void)openDisc
{
@synchronized (self) {
[o_specialMediaFolders removeAllObjects];
}
[self scanOpticalMedia: nil];
[self openTarget: 1];
}
- (void)openNet
{
[self openNetInfoChanged: nil];
[self openTarget: 2];
}
- (void)openCapture
{
[self openCaptureModeChanged: nil];
[self openTarget: 3];
}
- (void)openFile
{
NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
b_autoplay = config_GetInt(VLCIntf, "macosx-autoplay");
[o_open_panel setAllowsMultipleSelection: YES];
[o_open_panel setCanChooseDirectories: YES];
[o_open_panel setTitle: _NS("Open File")];
[o_open_panel setPrompt: _NS("Open")];
if ([o_open_panel runModal] == NSOKButton) {
NSArray * o_urls = [o_open_panel URLs];
NSUInteger count = [o_urls count];
NSMutableArray *o_values = [NSMutableArray arrayWithCapacity:count];
NSMutableArray *o_array = [NSMutableArray arrayWithCapacity:count];
for (NSUInteger i = 0; i < count; i++)
[o_values addObject: [[o_urls objectAtIndex:i] path]];
[o_values sortUsingSelector:@selector(caseInsensitiveCompare:)];
for (NSUInteger i = 0; i < count; i++) {
NSDictionary *o_dic;
char *psz_uri = vlc_path2uri([[o_values objectAtIndex:i] UTF8String], "file");
if (!psz_uri)
continue;
o_dic = [NSDictionary dictionaryWithObject:[NSString stringWithCString:psz_uri encoding:NSUTF8StringEncoding] forKey:@"ITEM_URL"];
free(psz_uri);
[o_array addObject: o_dic];
}
if (b_autoplay)
[[[VLCMain sharedInstance] playlist] appendArray: o_array atPos: -1 enqueue:NO];
else
[[[VLCMain sharedInstance] playlist] appendArray: o_array atPos: -1 enqueue:YES];
}
}
#pragma mark -
#pragma mark File Panel
- (void)openFilePathChanged:(NSNotification *)o_notification
{
if (o_file_path && [o_file_path length] > 0) {
bool b_stream = [o_file_stream state];
BOOL b_dir = NO;
[[NSFileManager defaultManager] fileExistsAtPath:o_file_path isDirectory:&b_dir];
char *psz_uri = vlc_path2uri([o_file_path UTF8String], "file");
if (!psz_uri) return;
NSMutableString *o_mrl_string = [NSMutableString stringWithUTF8String: psz_uri ];
NSRange offile = [o_mrl_string rangeOfString:@"file"];
free(psz_uri);
if (b_dir)
[o_mrl_string replaceCharactersInRange:offile withString: @"directory"];
else if (b_stream)
[o_mrl_string replaceCharactersInRange:offile withString: @"stream"];
[o_file_name setStringValue: [[NSFileManager defaultManager] displayNameAtPath:o_file_path]];
[o_file_name_stub setHidden: YES];
[o_file_stream setHidden: NO];
[o_file_icon_well setImage: [[NSWorkspace sharedWorkspace] iconForFile: o_file_path]];
[o_file_icon_well setHidden: NO];
[self setMRL: o_mrl_string];
} else {
[o_file_name setStringValue: @""];
[o_file_name_stub setHidden: NO];
[o_file_stream setHidden: YES];
[o_file_icon_well setImage: [NSImage imageNamed:@"generic"]];
[self setMRL: @""];
}
}
- (IBAction)openFileBrowse:(id)sender
{
NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
[o_open_panel setAllowsMultipleSelection: NO];
[o_open_panel setCanChooseDirectories: YES];
[o_open_panel setTitle: _NS("Open File")];
[o_open_panel setPrompt: _NS("Open")];
[o_open_panel beginSheetModalForWindow:[sender window] completionHandler:^(NSInteger returnCode) {
if (returnCode == NSFileHandlingPanelOKButton) {
if (o_file_path)
[o_file_path release];
o_file_path = [[[o_open_panel URLs] objectAtIndex:0] path];
[o_file_path retain];
[self openFilePathChanged: nil];
}
}];
}
- (IBAction)openFileStreamChanged:(id)sender
{
[self openFilePathChanged: nil];
}
- (IBAction)inputSlaveAction:(id)sender
{
if (sender == o_file_slave_ckbox)
[o_file_slave_select_btn setEnabled: [o_file_slave_ckbox state]];
else {
NSOpenPanel *o_open_panel;
o_open_panel = [NSOpenPanel openPanel];
[o_open_panel setCanChooseFiles: YES];
[o_open_panel setCanChooseDirectories: NO];
if ([o_open_panel runModal] == NSOKButton) {
if (o_file_slave_path)
[o_file_slave_path release];
o_file_slave_path = [[[o_open_panel URLs] objectAtIndex:0] path];
[o_file_slave_path retain];
}
}
if (o_file_slave_path && [o_file_slave_ckbox state] == NSOnState) {
[o_file_slave_filename_lbl setStringValue: [[NSFileManager defaultManager] displayNameAtPath:o_file_slave_path]];
[o_file_slave_icon_well setImage: [[NSWorkspace sharedWorkspace] iconForFile: o_file_slave_path]];
} else {
[o_file_slave_filename_lbl setStringValue: @""];
[o_file_slave_icon_well setImage: NULL];
}
}
- (IBAction)fileTimeCustomization:(id)sender
{
BOOL b_value = [o_file_custom_timing_ckb state];
[o_file_starttime_fld setEnabled: b_value];
[o_file_starttime_lbl setEnabled: b_value];
[o_file_stoptime_fld setEnabled: b_value];
[o_file_stoptime_lbl setEnabled: b_value];
}
#pragma mark -
#pragma mark Optical Media Panel
- (void)showOpticalMediaView: theView withIcon:(NSImage *)icon
{
NSRect o_view_rect;
o_view_rect = [theView frame];
[theView setFrame: NSMakeRect(233, 0, o_view_rect.size.width, o_view_rect.size.height)];
[theView setAutoresizesSubviews: YES];
if (o_currentOpticalMediaView) {
[[[[o_tabview tabViewItemAtIndex: [o_tabview indexOfTabViewItemWithIdentifier:@"optical"]] view] animator] replaceSubview: o_currentOpticalMediaView with: theView];
[o_currentOpticalMediaView release];
}
else
[[[[o_tabview tabViewItemAtIndex: [o_tabview indexOfTabViewItemWithIdentifier:@"optical"]] view] animator] addSubview: theView];
o_currentOpticalMediaView = theView;
[o_currentOpticalMediaView retain];
NSImageView *imageView;
imageView = [[NSImageView alloc] init];
[imageView setFrame: NSMakeRect(53, 61, 128, 128)];
[icon setSize: NSMakeSize(128,128)];
[imageView setImage: icon];
if (o_currentOpticalMediaIconView) {
[[[[o_tabview tabViewItemAtIndex: [o_tabview indexOfTabViewItemWithIdentifier:@"optical"]] view] animator] replaceSubview: o_currentOpticalMediaIconView with: imageView];
[o_currentOpticalMediaIconView release];
}
else
[[[[o_tabview tabViewItemAtIndex: [o_tabview indexOfTabViewItemWithIdentifier:@"optical"]] view] animator] addSubview: imageView];
o_currentOpticalMediaIconView = imageView;
[o_currentOpticalMediaIconView retain];
[o_currentOpticalMediaView setNeedsDisplay: YES];
[o_currentOpticalMediaIconView setNeedsDisplay: YES];
[[[o_tabview tabViewItemAtIndex: [o_tabview indexOfTabViewItemWithIdentifier:@"optical"]] view] setNeedsDisplay: YES];
[[[o_tabview tabViewItemAtIndex: [o_tabview indexOfTabViewItemWithIdentifier:@"optical"]] view] displayIfNeeded];
}
+ (NSString *) getBSDNodeFromMountPath:(NSString *)mountPath
{
OSStatus err;
FSRef ref;
FSVolumeRefNum actualVolume;
err = FSPathMakeRef ((const UInt8 *) [mountPath fileSystemRepresentation], &ref, NULL);
// get a FSVolumeRefNum from mountPath
if (noErr == err) {
FSCatalogInfo catalogInfo;
err = FSGetCatalogInfo (&ref,
kFSCatInfoVolume,
&catalogInfo,
NULL,
NULL,
NULL
);
if (noErr == err)
actualVolume = catalogInfo.volume;
else
return @"";
}
else
return @"";
GetVolParmsInfoBuffer volumeParms;
err = FSGetVolumeParms(actualVolume, &volumeParms, sizeof(volumeParms));
if (noErr == err) {
NSString *bsdName = [NSString stringWithUTF8String:(char *)volumeParms.vMDeviceID];
return [NSString stringWithFormat:@"/dev/r%@", bsdName];
}
return @"";
}
+ (NSString *)getVolumeTypeFromMountPath:(NSString *)mountPath
{
OSStatus err;
FSRef ref;
FSVolumeRefNum actualVolume;
err = FSPathMakeRef ((const UInt8 *) [mountPath fileSystemRepresentation], &ref, NULL);
// get a FSVolumeRefNum from mountPath
if (noErr == err) {
FSCatalogInfo catalogInfo;
err = FSGetCatalogInfo (&ref,
kFSCatInfoVolume,
&catalogInfo,
NULL,
NULL,
NULL
);
if (noErr == err)
actualVolume = catalogInfo.volume;
else
goto out;
}
else
goto out;
GetVolParmsInfoBuffer volumeParms;
err = FSGetVolumeParms(actualVolume, &volumeParms, sizeof(volumeParms));
CFMutableDictionaryRef matchingDict;
io_service_t service;
if (!volumeParms.vMDeviceID) {
goto out;
}
matchingDict = IOBSDNameMatching(kIOMasterPortDefault, 0, volumeParms.vMDeviceID);
service = IOServiceGetMatchingService(kIOMasterPortDefault, matchingDict);
NSString *returnValue = nil;
if (IO_OBJECT_NULL != service) {
if (IOObjectConformsTo(service, kIOCDMediaClass))
returnValue = kVLCMediaAudioCD;
else if (IOObjectConformsTo(service, kIODVDMediaClass))
returnValue = kVLCMediaDVD;
else if (IOObjectConformsTo(service, kIOBDMediaClass))
returnValue = kVLCMediaBD;
IOObjectRelease(service);
if (returnValue)
return returnValue;
}
out:
if ([mountPath rangeOfString:@"VIDEO_TS" options:NSCaseInsensitiveSearch | NSBackwardsSearch].location != NSNotFound)
returnValue = kVLCMediaVideoTSFolder;
else if ([mountPath rangeOfString:@"BDMV" options:NSCaseInsensitiveSearch | NSBackwardsSearch].location != NSNotFound)
returnValue = kVLCMediaBDMVFolder;
else {
// NSFileManager is not thread-safe, don't use defaultManager outside of the main thread
NSFileManager * fm = [[NSFileManager alloc] init];
NSArray *dirContents = [fm contentsOfDirectoryAtPath:mountPath error:nil];
for (int i = 0; i < [dirContents count]; i++) {
NSString *currentFile = [dirContents objectAtIndex:i];
NSString *fullPath = [mountPath stringByAppendingPathComponent:currentFile];
BOOL isDir;
if ([fm fileExistsAtPath:fullPath isDirectory:&isDir] && isDir)
{
if ([currentFile caseInsensitiveCompare:@"SVCD"] == NSOrderedSame) {
returnValue = kVLCMediaSVCD;
break;
}
if ([currentFile caseInsensitiveCompare:@"VCD"] == NSOrderedSame) {
returnValue = kVLCMediaVCD;
break;
}
if ([currentFile caseInsensitiveCompare:@"BDMV"] == NSOrderedSame) {
returnValue = kVLCMediaBDMVFolder;
break;
}
if ([currentFile caseInsensitiveCompare:@"VIDEO_TS"] == NSOrderedSame) {
returnValue = kVLCMediaVideoTSFolder;
break;
}
}
}
[fm release];
if (!returnValue)
returnValue = kVLCMediaVideoTSFolder;
}
return returnValue;
}
- (void)showOpticalAtPath: (NSDictionary *)o_dict
{
NSString *diskType = [o_dict objectForKey:@"mediaType"];
NSString *o_opticalDevicePath = [o_dict objectForKey:@"path"];
NSString *o_device_path = [o_dict objectForKey:@"devicePath"];
NSImage *o_image = [o_dict objectForKey:@"image"];
if ([diskType isEqualToString: kVLCMediaDVD] || [diskType isEqualToString: kVLCMediaVideoTSFolder]) {
[o_disc_dvd_lbl setStringValue: [[NSFileManager defaultManager] displayNameAtPath:o_opticalDevicePath]];
[o_disc_dvdwomenus_lbl setStringValue: [o_disc_dvd_lbl stringValue]];
if (!b_nodvdmenus) {
[self setMRL: [NSString stringWithFormat: @"dvdnav://%@", o_device_path]];
[self showOpticalMediaView: o_disc_dvd_view withIcon:o_image];
} else {
[self setMRL: [NSString stringWithFormat: @"dvdread://%@#%i:%i-", o_device_path, [o_disc_dvdwomenus_title intValue], [o_disc_dvdwomenus_chapter intValue]]];
[self showOpticalMediaView: o_disc_dvdwomenus_view withIcon: o_image];
}
} else if ([diskType isEqualToString: kVLCMediaAudioCD]) {
[o_disc_audiocd_lbl setStringValue: [[NSFileManager defaultManager] displayNameAtPath: o_opticalDevicePath]];
[o_disc_audiocd_trackcount_lbl setStringValue: [NSString stringWithFormat:_NS("%i tracks"), [[[NSFileManager defaultManager] subpathsOfDirectoryAtPath: o_opticalDevicePath error:NULL] count] - 1]]; // minus .TOC.plist
[self showOpticalMediaView: o_disc_audiocd_view withIcon: o_image];
[self setMRL: [NSString stringWithFormat: @"cdda://%@", o_device_path]];
} else if ([diskType isEqualToString: kVLCMediaVCD]) {
[o_disc_vcd_lbl setStringValue: [[NSFileManager defaultManager] displayNameAtPath: o_opticalDevicePath]];
[self showOpticalMediaView: o_disc_vcd_view withIcon: o_image];
[self setMRL: [NSString stringWithFormat: @"vcd://%@#%i:%i", o_device_path, [o_disc_vcd_title intValue], [o_disc_vcd_chapter intValue]]];
} else if ([diskType isEqualToString: kVLCMediaSVCD]) {
[o_disc_vcd_lbl setStringValue: [[NSFileManager defaultManager] displayNameAtPath: o_opticalDevicePath]];
[self showOpticalMediaView: o_disc_vcd_view withIcon: o_image];
[self setMRL: [NSString stringWithFormat: @"vcd://%@@%i:%i", o_device_path, [o_disc_vcd_title intValue], [o_disc_vcd_chapter intValue]]];
} else if ([diskType isEqualToString: kVLCMediaBD] || [diskType isEqualToString: kVLCMediaBDMVFolder]) {
[o_disc_bd_lbl setStringValue: [[NSFileManager defaultManager] displayNameAtPath: o_opticalDevicePath]];
[self showOpticalMediaView: o_disc_bd_view withIcon: o_image];
[self setMRL: [NSString stringWithFormat: @"bluray://%@", o_opticalDevicePath]];
} else {
if (VLCIntf)
msg_Warn(VLCIntf, "unknown disk type, no idea what to display");
[self showOpticalMediaView: o_disc_nodisc_view withIcon: [NSImage imageNamed:@"NSApplicationIcon"]];
}
}
- (NSDictionary *)scanPath:(NSString *)o_path
{
NSString *o_type = [VLCOpen getVolumeTypeFromMountPath:o_path];
NSImage *o_image = [[NSWorkspace sharedWorkspace] iconForFile: o_path];
NSString *o_device_path;
// BDMV path must not end with BDMV directory
if([o_type isEqualToString: kVLCMediaBDMVFolder]) {
if([[o_path lastPathComponent] isEqualToString: @"BDMV"]) {
o_path = [o_path stringByDeletingLastPathComponent];
}
}
if ([o_type isEqualToString: kVLCMediaVideoTSFolder] ||
[o_type isEqualToString: kVLCMediaBD] ||
[o_type isEqualToString: kVLCMediaBDMVFolder] ||
[o_type isEqualToString: kVLCMediaUnknown])
o_device_path = o_path;
else
o_device_path = [VLCOpen getBSDNodeFromMountPath:o_path];
return [NSDictionary dictionaryWithObjectsAndKeys: o_path, @"path",
o_device_path, @"devicePath",
o_type, @"mediaType",
o_image, @"image", nil];
}
- (void)scanDevicesWithPaths:(NSArray *)o_paths
{
NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
NSUInteger count = [o_paths count];
NSMutableArray *o_result = [NSMutableArray arrayWithCapacity:count];
for (NSUInteger i = 0; i < count; i++)
[o_result addObject: [self scanPath:[o_paths objectAtIndex:i]]];
@synchronized (self) {
if (o_opticalDevices)
[o_opticalDevices release];
o_opticalDevices = [[NSArray alloc] initWithArray: o_result];
}
[self performSelectorOnMainThread:@selector(updateMediaSelector:) withObject:nil waitUntilDone:NO];
[o_pool release];
}
- (void)scanSpecialPath:(NSString *)o_path
{
NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
NSDictionary *o_dict = [self scanPath:o_path];
@synchronized (self) {
[o_specialMediaFolders addObject:o_dict];
}
[self performSelectorOnMainThread:@selector(updateMediaSelector:) withObject:[NSNumber numberWithBool:YES] waitUntilDone:NO];
[o_pool release];
}
- (void)scanOpticalMedia:(NSNotification *)o_notification
{
[NSThread detachNewThreadSelector:@selector(scanDevicesWithPaths:) toTarget:self withObject:[NSArray arrayWithArray:[[NSWorkspace sharedWorkspace] mountedRemovableMedia]]];
}
- (void)updateMediaSelector:(NSNumber *)o_selection
{
[o_allMediaDevices removeAllObjects];
[o_disc_selector_pop removeAllItems];
@synchronized (self) {
[o_allMediaDevices addObjectsFromArray:o_opticalDevices];
[o_allMediaDevices addObjectsFromArray:o_specialMediaFolders];
}
NSUInteger count = [o_allMediaDevices count];
if (count > 0) {
for (NSUInteger i = 0; i < count ; i++) {
NSDictionary *o_dict = [o_allMediaDevices objectAtIndex:i];
[o_disc_selector_pop addItemWithTitle: [[NSFileManager defaultManager] displayNameAtPath:[o_dict objectForKey:@"path"]]];
}
if ([o_disc_selector_pop numberOfItems] <= 1)
[o_disc_selector_pop setHidden: YES];
else
[o_disc_selector_pop setHidden: NO];
// select newly added media folder
if (o_selection && [o_selection boolValue])
[o_disc_selector_pop selectItemAtIndex: [[o_disc_selector_pop itemArray] count] - 1];
[self discSelectorChanged:nil];
} else {
msg_Dbg(VLCIntf, "no optical media found");
[o_disc_selector_pop setHidden: YES];
[self showOpticalMediaView: o_disc_nodisc_view withIcon: [NSImage imageNamed: @"NSApplicationIcon"]];
}
}
- (IBAction)discSelectorChanged:(id)sender
{
NSDictionary *o_dict = [o_allMediaDevices objectAtIndex:[o_disc_selector_pop indexOfSelectedItem]];
[self showOpticalAtPath:o_dict];
}
- (IBAction)openSpecialMediaFolder:(id)sender
{
/* this is currently for VIDEO_TS and BDMV folders */
NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
[o_open_panel setAllowsMultipleSelection: NO];
[o_open_panel setCanChooseDirectories: YES];
[o_open_panel setTitle: [sender title]];
[o_open_panel setPrompt: _NS("Open")];
/* work-around for Mountain Lion, which treats folders called "BDMV" including an item named "INDEX.BDM"
* as a _FILE_. Don't ask, move on. There is nothing to see here */
[o_open_panel setCanChooseFiles: YES];
[o_open_panel setAllowedFileTypes:[NSArray arrayWithObject:@"public.directory"]];
if ([o_open_panel runModal] == NSOKButton) {
NSString *o_path = [[[o_open_panel URLs] objectAtIndex:0] path];
if ([o_path length] > 0) {
[NSThread detachNewThreadSelector:@selector(scanSpecialPath:) toTarget:self withObject:o_path];
}
}
}
- (IBAction)dvdreadOptionChanged:(id)sender
{
NSDictionary *o_dict = [o_allMediaDevices objectAtIndex:[o_disc_selector_pop indexOfSelectedItem]];
NSString *o_device_path = [o_dict objectForKey:@"devicePath"];
if (sender == o_disc_dvdwomenus_enablemenus_btn) {
b_nodvdmenus = NO;
[self setMRL: [NSString stringWithFormat: @"dvdnav://%@", o_device_path]];
[self showOpticalMediaView: o_disc_dvd_view withIcon: [o_currentOpticalMediaIconView image]];
return;
}
if (sender == o_disc_dvd_disablemenus_btn) {
b_nodvdmenus = YES;
[self showOpticalMediaView: o_disc_dvdwomenus_view withIcon: [o_currentOpticalMediaIconView image]];
}
if (sender == o_disc_dvdwomenus_title)
[o_disc_dvdwomenus_title_stp setIntValue: [o_disc_dvdwomenus_title intValue]];
if (sender == o_disc_dvdwomenus_title_stp)
[o_disc_dvdwomenus_title setIntValue: [o_disc_dvdwomenus_title_stp intValue]];
if (sender == o_disc_dvdwomenus_chapter)
[o_disc_dvdwomenus_chapter_stp setIntValue: [o_disc_dvdwomenus_chapter intValue]];
if (sender == o_disc_dvdwomenus_chapter_stp)
[o_disc_dvdwomenus_chapter setIntValue: [o_disc_dvdwomenus_chapter_stp intValue]];
[self setMRL: [NSString stringWithFormat: @"dvdread://%@#%i:%i-", o_device_path, [o_disc_dvdwomenus_title intValue], [o_disc_dvdwomenus_chapter intValue]]];
}
- (IBAction)vcdOptionChanged:(id)sender
{
if (sender == o_disc_vcd_title)
[o_disc_vcd_title_stp setIntValue: [o_disc_vcd_title intValue]];
if (sender == o_disc_vcd_title_stp)
[o_disc_vcd_title setIntValue: [o_disc_vcd_title_stp intValue]];
if (sender == o_disc_vcd_chapter)
[o_disc_vcd_chapter_stp setIntValue: [o_disc_vcd_chapter intValue]];
if (sender == o_disc_vcd_chapter_stp)
[o_disc_vcd_chapter setIntValue: [o_disc_vcd_chapter_stp intValue]];
NSString *o_device_path = [[o_allMediaDevices objectAtIndex:[o_disc_selector_pop indexOfSelectedItem]] objectForKey:@"devicePath"];
[self setMRL: [NSString stringWithFormat: @"vcd://%@@%i:%i", o_device_path, [o_disc_vcd_title intValue], [o_disc_vcd_chapter intValue]]];
}
#pragma mark -
#pragma mark Network Panel
- (void)textFieldWasClicked:(NSNotification *)o_notification
{
if ([o_notification object] == o_net_udp_port)
[o_net_mode selectCellAtRow: 0 column: 0];
else if ([o_notification object] == o_net_udpm_addr ||
[o_notification object] == o_net_udpm_port)
[o_net_mode selectCellAtRow: 1 column: 0];
else
[o_net_mode selectCellAtRow: 2 column: 0];
[self openNetInfoChanged: nil];
}
- (IBAction)openNetModeChanged:(id)sender
{
if (sender == o_net_mode) {
if ([[sender selectedCell] tag] == 0)
[o_panel makeFirstResponder: o_net_udp_port];
else if ([[sender selectedCell] tag] == 1)
[o_panel makeFirstResponder: o_net_udpm_addr];
else
msg_Warn(VLCIntf, "Unknown sender tried to change UDP/RTP mode");
}
[self openNetInfoChanged: nil];
}
- (IBAction)openNetStepperChanged:(id)sender
{
int i_tag = [sender tag];
if (i_tag == 0) {
[o_net_udp_port setIntValue: [o_net_udp_port_stp intValue]];
[[NSNotificationCenter defaultCenter] postNotificationName: @"VLCOpenTextFieldWasClicked"
object: o_net_udp_port];
[o_panel makeFirstResponder: o_net_udp_port];
}
else if (i_tag == 1) {
[o_net_udpm_port setIntValue: [o_net_udpm_port_stp intValue]];
[[NSNotificationCenter defaultCenter] postNotificationName: @"VLCOpenTextFieldWasClicked"
object: o_net_udpm_port];
[o_panel makeFirstResponder: o_net_udpm_port];
}
[self openNetInfoChanged: nil];
}
- (void)openNetInfoChanged:(NSNotification *)o_notification
{
NSString *o_mrl_string = [NSString string];
if ([o_net_udp_panel isVisible]) {
NSString *o_mode;
o_mode = [[o_net_mode selectedCell] title];
if ([o_mode isEqualToString: _NS("Unicast")]) {
int i_port = [o_net_udp_port intValue];
if ([[o_net_udp_protocol_mat selectedCell] tag] == 0)
o_mrl_string = @"udp://";
else
o_mrl_string = @"rtp://";
if (i_port != config_GetInt(VLCIntf, "server-port")) {
o_mrl_string =
[o_mrl_string stringByAppendingFormat: @"@:%i", i_port];
}
}
else if ([o_mode isEqualToString: _NS("Multicast")]) {
NSString *o_addr = [o_net_udpm_addr stringValue];
int i_port = [o_net_udpm_port intValue];
if ([[o_net_udp_protocol_mat selectedCell] tag] == 0)
o_mrl_string = [NSString stringWithFormat: @"udp://@%@", o_addr];
else
o_mrl_string = [NSString stringWithFormat: @"rtp://@%@", o_addr];
if (i_port != config_GetInt(VLCIntf, "server-port")) {
o_mrl_string =
[o_mrl_string stringByAppendingFormat: @":%i", i_port];
}
}
} else
o_mrl_string = [o_net_http_url stringValue];
[self setMRL: o_mrl_string];
}
- (IBAction)openNetUDPButtonAction:(id)sender
{
if (sender == o_net_openUDP_btn) {
[NSApp beginSheet: o_net_udp_panel
modalForWindow: o_panel
modalDelegate: self
didEndSelector: NULL
contextInfo: nil];
[self openNetInfoChanged: nil];
}
else if (sender == o_net_udp_cancel_btn) {
[o_net_udp_panel orderOut: sender];
[NSApp endSheet: o_net_udp_panel];
}
else if (sender == o_net_udp_ok_btn) {
NSString *o_mrl_string = [NSString string];
if ([[[o_net_mode selectedCell] title] isEqualToString: _NS("Unicast")]) {
int i_port = [o_net_udp_port intValue];
if ([[o_net_udp_protocol_mat selectedCell] tag] == 0)
o_mrl_string = @"udp://";
else
o_mrl_string = @"rtp://";
if (i_port != config_GetInt(VLCIntf, "server-port")) {
o_mrl_string =
[o_mrl_string stringByAppendingFormat: @"@:%i", i_port];
}
}
else if ([[[o_net_mode selectedCell] title] isEqualToString: _NS("Multicast")]) {
NSString *o_addr = [o_net_udpm_addr stringValue];
int i_port = [o_net_udpm_port intValue];
if ([[o_net_udp_protocol_mat selectedCell] tag] == 0)
o_mrl_string = [NSString stringWithFormat: @"udp://@%@", o_addr];
else
o_mrl_string = [NSString stringWithFormat: @"rtp://@%@", o_addr];
if (i_port != config_GetInt(VLCIntf, "server-port")) {
o_mrl_string =
[o_mrl_string stringByAppendingFormat: @":%i", i_port];
}
}
[self setMRL: o_mrl_string];
[o_net_http_url setStringValue: o_mrl_string];
[o_net_udp_panel orderOut: sender];
[NSApp endSheet: o_net_udp_panel];
}
}
#pragma mark -
#pragma mark Capture Panel
- (void)showCaptureView: theView
{
NSRect o_view_rect;
o_view_rect = [theView frame];
[theView setFrame: NSMakeRect(0, -10, o_view_rect.size.width, o_view_rect.size.height)];
[theView setAutoresizesSubviews: YES];
if (o_currentCaptureView) {
[[[[o_tabview tabViewItemAtIndex: 3] view] animator] replaceSubview: o_currentCaptureView with: theView];
[o_currentCaptureView release];
} else {
[[[[o_tabview tabViewItemAtIndex: 3] view] animator] addSubview: theView];
}
o_currentCaptureView = theView;
[o_currentCaptureView retain];
}
- (IBAction)openCaptureModeChanged:(id)sender
{
intf_thread_t * p_intf = VLCIntf;
if ([[[o_capture_mode_pop selectedItem] title] isEqualToString: @"EyeTV"]) {
if ([[[VLCMain sharedInstance] eyeTVController] eyeTVRunning] == YES) {
if ([[[VLCMain sharedInstance] eyeTVController] deviceConnected] == YES) {
[self showCaptureView: o_eyetv_running_view];
[self setupChannelInfo];
}
else
setEyeTVUnconnected;
}
else
[self showCaptureView: o_eyetv_notLaunched_view];
[self setMRL: @""];
}
else if ([[[o_capture_mode_pop selectedItem] title] isEqualToString: _NS("Screen")]) {
[self showCaptureView: o_screen_view];
[self setMRL: @"screen://"];
[o_screen_height_fld setIntValue: config_GetInt(p_intf, "screen-height")];
[o_screen_width_fld setIntValue: config_GetInt(p_intf, "screen-width")];
[o_screen_fps_fld setFloatValue: config_GetFloat(p_intf, "screen-fps")];
[o_screen_left_fld setIntValue: config_GetInt(p_intf, "screen-left")];
[o_screen_top_fld setIntValue: config_GetInt(p_intf, "screen-top")];
[o_screen_follow_mouse_ckb setIntValue: config_GetInt(p_intf, "screen-follow-mouse")];
int screen_index = config_GetInt(p_intf, "screen-index");
int display_id = config_GetInt(p_intf, "screen-display-id");
unsigned int i, displayCount = 0;
CGLError returnedError;
struct display_info_t *item;
NSValue *v;
returnedError = CGGetOnlineDisplayList(0, NULL, &displayCount);
if (!returnedError) {
CGDirectDisplayID *ids;
ids = (CGDirectDisplayID *)malloc(displayCount * sizeof(CGDirectDisplayID));
returnedError = CGGetOnlineDisplayList(displayCount, ids, &displayCount);
if (!returnedError) {
for (i = 0; i < [o_displayInfos count]; i ++) {
v = [o_displayInfos objectAtIndex:i];
free([v pointerValue]);
}
[o_displayInfos removeAllObjects];
[o_screen_screen_pop removeAllItems];
for (i = 0; i < displayCount; i ++) {
item = (struct display_info_t *)malloc(sizeof(struct display_info_t));
item->id = ids[i];
item->rect = CGDisplayBounds(item->id);
[o_screen_screen_pop addItemWithTitle: [NSString stringWithFormat:@"Screen %d (%dx%d)", i + 1, (int)item->rect.size.width, (int)item->rect.size.height]];
v = [NSValue valueWithPointer:item];
[o_displayInfos addObject:v];
if (i == 0 || display_id == item->id || screen_index - 1 == i) {
[o_screen_screen_pop selectItemAtIndex: i];
[o_screen_left_stp setMaxValue: item->rect.size.width];
[o_screen_top_stp setMaxValue: item->rect.size.height];
[o_screen_width_stp setMaxValue: item->rect.size.width];
[o_screen_height_stp setMaxValue: item->rect.size.height];
}
}
}
free(ids);
}
}
else if ([[[o_capture_mode_pop selectedItem] title] isEqualToString: _NS("Input Devices")]) {
[self showCaptureView: o_qtk_view];
if ([o_capture_width_fld intValue] <= 0)
[self qtkChanged:nil];
[self qtkAudioChanged:nil];
[self setMRL: @""];
if ([o_qtk_video_ckb state] && qtk_currdevice_uid)
[self setMRL:[NSString stringWithFormat:@"qtcapture://%@", qtk_currdevice_uid]];
else if ([o_qtk_audio_ckb state] && qtkaudio_currdevice_uid)
[self setMRL:[NSString stringWithFormat:@"qtsound://%@", qtkaudio_currdevice_uid]];
}
}
- (void)screenFPSfieldChanged:(NSNotification *)o_notification
{
[o_screen_fps_stp setFloatValue: [o_screen_fps_fld floatValue]];
if ([[o_screen_fps_fld stringValue] isEqualToString: @""])
[o_screen_fps_fld setFloatValue: 1.0];
[self setMRL: @"screen://"];
}
- (IBAction)eyetvSwitchChannel:(id)sender
{
if (sender == o_eyetv_nextProgram_btn) {
int chanNum = [[[VLCMain sharedInstance] eyeTVController] switchChannelUp: YES];
[o_eyetv_channels_pop selectItemWithTag:chanNum];
[self setMRL: [NSString stringWithFormat:@"eyetv:// :eyetv-channel=%d", chanNum]];
} else if (sender == o_eyetv_previousProgram_btn) {
int chanNum = [[[VLCMain sharedInstance] eyeTVController] switchChannelUp: NO];
[o_eyetv_channels_pop selectItemWithTag:chanNum];
[self setMRL: [NSString stringWithFormat:@"eyetv:// :eyetv-channel=%d", chanNum]];
} else if (sender == o_eyetv_channels_pop) {
int chanNum = [[sender selectedItem] tag];
[[[VLCMain sharedInstance] eyeTVController] setChannel:chanNum];
[self setMRL: [NSString stringWithFormat:@"eyetv:// :eyetv-channel=%d", chanNum]];
} else
msg_Err(VLCIntf, "eyetvSwitchChannel sent by unknown object");
}
- (IBAction)eyetvLaunch:(id)sender
{
[[[VLCMain sharedInstance] eyeTVController] launchEyeTV];
}
- (IBAction)eyetvGetPlugin:(id)sender
{
[[NSWorkspace sharedWorkspace] openURL: [NSURL URLWithString: @"http://www.videolan.org/vlc/eyetv"]];
}
- (void)eyetvChanged:(NSNotification *)o_notification
{
if ([[o_notification name] isEqualToString: @"DeviceAdded"]) {
msg_Dbg(VLCIntf, "eyetv device was added");
[self showCaptureView: o_eyetv_running_view];
[self setupChannelInfo];
} else if ([[o_notification name] isEqualToString: @"DeviceRemoved"]) {
/* leave the channel selection like that,
* switch to our "no device" tab */
msg_Dbg(VLCIntf, "eyetv device was removed");
setEyeTVUnconnected;
} else if ([[o_notification name] isEqualToString: @"PluginQuit"]) {
/* switch to the "launch eyetv" tab */
msg_Dbg(VLCIntf, "eyetv was terminated");
[self showCaptureView: o_eyetv_notLaunched_view];
} else if ([[o_notification name] isEqualToString: @"PluginInit"]) {
/* we got no device yet */
msg_Dbg(VLCIntf, "eyetv was launched, no device yet");
setEyeTVUnconnected;
}
}
/* little helper method, since this code needs to be run by multiple objects */
- (void)setupChannelInfo
{
/* set up channel selection */
[o_eyetv_channels_pop removeAllItems];
[o_eyetv_chn_bgbar setHidden: NO];
[o_eyetv_chn_bgbar animate: self];
[o_eyetv_chn_status_txt setStringValue: _NS("Retrieving Channel Info...")];
[o_eyetv_chn_status_txt setHidden: NO];
/* retrieve info */
NSEnumerator *channels = [[[VLCMain sharedInstance] eyeTVController] allChannels];
int x = -2;
[[[o_eyetv_channels_pop menu] addItemWithTitle: _NS("Composite input")
action: nil
keyEquivalent: @""] setTag:x++];
[[[o_eyetv_channels_pop menu] addItemWithTitle: _NS("S-Video input")
action: nil
keyEquivalent: @""] setTag:x++];
if (channels) {
NSString *channel;
[[o_eyetv_channels_pop menu] addItem: [NSMenuItem separatorItem]];
while ((channel = [channels nextObject]) != nil)
/* we have to add items this way, because we accept duplicates
* additionally, we save a bit of time */
[[[o_eyetv_channels_pop menu] addItemWithTitle: channel action: nil keyEquivalent: @""] setTag:++x];
/* make Tuner the default */
[o_eyetv_channels_pop selectItemWithTag:[[[VLCMain sharedInstance] eyeTVController] channel]];
}
/* clean up GUI */
[o_eyetv_chn_bgbar setHidden: YES];
[o_eyetv_chn_status_txt setHidden: YES];
}
#pragma mark -
#pragma mark Subtitle Settings
- (IBAction)subsChanged:(id)sender
{
if ([o_file_sub_ckbox state] == NSOnState) {
[o_file_sub_btn_settings setEnabled:YES];
if (o_sub_path) {
[o_file_subtitles_filename_lbl setStringValue: [[NSFileManager defaultManager] displayNameAtPath:o_sub_path]];
[o_file_subtitles_icon_well setImage: [[NSWorkspace sharedWorkspace] iconForFile:o_sub_path]];
}
} else {
[o_file_sub_btn_settings setEnabled:NO];
[o_file_subtitles_filename_lbl setStringValue: @""];
[o_file_subtitles_icon_well setImage: NULL];
}
}
- (IBAction)subSettings:(id)sender
{
[NSApp beginSheet: o_file_sub_sheet
modalForWindow: [sender window]
modalDelegate: self
didEndSelector: NULL
contextInfo: nil];
}
- (IBAction)subCloseSheet:(id)sender
{
[self subsChanged: nil];
[o_file_sub_sheet orderOut:sender];
[NSApp endSheet: o_file_sub_sheet];
}
- (IBAction)subFileBrowse:(id)sender
{
NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
[o_open_panel setAllowsMultipleSelection: NO];
[o_open_panel setTitle: _NS("Open File")];
[o_open_panel setPrompt: _NS("Open")];
if ([o_open_panel runModal] == NSOKButton) {
o_sub_path = [[[o_open_panel URLs] objectAtIndex:0] path];
[o_sub_path retain];
[o_file_subtitles_filename_lbl setStringValue: [[NSFileManager defaultManager] displayNameAtPath:o_sub_path]];
[o_file_sub_path_fld setStringValue: [o_file_subtitles_filename_lbl stringValue]];
[o_file_sub_path_lbl setHidden: YES];
[o_file_subtitles_icon_well setImage: [[NSWorkspace sharedWorkspace] iconForFile:o_sub_path]];
[o_file_sub_icon_view setImage: [o_file_subtitles_icon_well image]];
} else {
[o_file_sub_path_lbl setHidden: NO];
[o_file_sub_path_fld setStringValue:@""];
[o_file_subtitles_filename_lbl setStringValue:@""];
[o_file_subtitles_icon_well setImage: nil];
[o_file_sub_icon_view setImage: nil];
}
}
- (IBAction)subOverride:(id)sender
{
BOOL b_state = [o_file_sub_override state];
[o_file_sub_delay setEnabled: b_state];
[o_file_sub_delay_stp setEnabled: b_state];
[o_file_sub_fps setEnabled: b_state];
[o_file_sub_fps_stp setEnabled: b_state];
}
#pragma mark -
#pragma mark Miscellaneous
- (IBAction)panelCancel:(id)sender
{
[NSApp stopModalWithCode: 0];
}
- (IBAction)panelOk:(id)sender
{
if ([[self MRL] length])
[NSApp stopModalWithCode: 1];
else
NSBeep();
}
- (NSArray *)qtkvideoDevices
{
if (!qtkvideoDevices)
[self qtkrefreshVideoDevices];
return qtkvideoDevices;
}
- (void)qtkrefreshVideoDevices
{
[qtkvideoDevices release];
qtkvideoDevices = [[[QTCaptureDevice inputDevicesWithMediaType:QTMediaTypeVideo] arrayByAddingObjectsFromArray:[QTCaptureDevice inputDevicesWithMediaType:QTMediaTypeMuxed]] retain];
}
- (NSArray *)qtkaudioDevices
{
if (!qtkaudioDevices)
[self qtkrefreshAudioDevices];
return qtkaudioDevices;
}
- (void)qtkrefreshAudioDevices
{
[qtkaudioDevices release];
qtkaudioDevices = [[[QTCaptureDevice inputDevicesWithMediaType:QTMediaTypeSound] arrayByAddingObjectsFromArray:[QTCaptureDevice inputDevicesWithMediaType:QTMediaTypeMuxed]] retain];
}
@end
@implementation VLCOpenTextField
- (void)mouseDown:(NSEvent *)theEvent
{
[[NSNotificationCenter defaultCenter] postNotificationName: @"VLCOpenTextFieldWasClicked"
object: self];
[super mouseDown: theEvent];
}
@end
|