home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / videotlk.zip / SAMPLES / DIVE / DIVE.C < prev    next >
Text File  |  2000-04-28  |  6KB  |  200 lines

  1. //#define DEBUG
  2. #define VCAI_ENABLED
  3. #define DIVE_ENABLED
  4. #define VCAI_MONITOR
  5.  
  6. #define INCL_DOS
  7. #define INCL_DOSERRORS
  8. #define INCL_GPI
  9. #define INCL_WIN
  10. #define INCL_32
  11.  
  12. #include <os2.h>
  13. #include <stdio.h>
  14. #include <stdlib.h>
  15. #include <string.h>
  16.  
  17. #define  _MEERROR_H_
  18. #include <mmioos2.h>                   /* It is from MMPM toolkit           */
  19. #include <dive.h>
  20. #include <fourcc.h>
  21. #include <vcadd.h>
  22. #include <vcai.h>
  23.  
  24. #include "dive.h"
  25. #include "pmtv2rem.h"
  26.  
  27. PWINDATA DiveSetup (char *name, USHORT instance, USHORT connector);
  28. int DiveRegister (HAB hab);
  29. int DiveStop (void);
  30.  
  31. /* Information about the system                                             */
  32. PFN             InsertAddr;                 /* Function for inserting?      */
  33. static PSZ      InsertName = "InsertPage";  /* Function name                */
  34. static HMODULE  HmodInsert;                 /* Module handle                */
  35.  
  36. static  PSZ     RemoteName = "RemoteDlgProc";   /* Remote control           */
  37. static  PFN     RemoteAddr;
  38. static  HMODULE HmodRemote;
  39.  
  40. static HWND     HwndRemote;         /* Remote control window hanle          */
  41. // static BOOL     RemoteOpen = FALSE;
  42. // extern BOOL     RemOpen;
  43.  
  44. /* This is the main function of the WinCast TV application.                 */
  45. int main (int argc, char *argv[])
  46. {
  47. HAB     hab;                /* Something....                                */
  48. HMQ     hmq;                /* Message queue handle                         */
  49. QMSG    qmsg;               /* Message from message queue                   */
  50. ULONG   rc;
  51. PSZ     pmmbase, env = "MMBASE";    /* Multimedia base directory            */
  52. char    mod_txt[256], txt[256], *p;
  53. ULONG   connector = 0;
  54. DRIVERHANDLE vhandle;
  55. PWINDATA wtv_datap;
  56.  
  57.  
  58.     /* Initialise the PM and create the message queue                       */
  59.     hab = WinInitialize (0);
  60.     hmq = WinCreateMsgQueue (hab, 0);
  61.  
  62.     /* Check the arguments and exit if necessary                            */
  63.     if ((argc < 3) || (argc > 4))
  64.     {
  65.         WinMessageBox (HWND_DESKTOP, HWND_DESKTOP,
  66.                        (PSZ)"Usage: WTV <name> <number> <connector>",
  67.                        (PSZ)WTV_NAME,
  68.                        0, MB_OK | MB_INFORMATION);
  69.  
  70.         WinDestroyMsgQueue (hmq);
  71.         WinTerminate (hab);
  72.         return 1;
  73.     }
  74.     if (argc == 4)
  75.         connector = (USHORT)atoi (argv[3]);
  76.  
  77.     wtv_datap = DiveSetup (argv[1], atoi(argv[2]), connector);
  78.     if (!wtv_datap)
  79.     {
  80.         sprintf (txt, "Unable to setup DIVE");
  81.         WinMessageBox (HWND_DESKTOP, HWND_DESKTOP,
  82.                        txt,
  83.                        (PSZ)WTV_NAME,
  84.                        0, MB_OK | MB_INFORMATION);
  85.  
  86.         WinDestroyMsgQueue (hmq);
  87.         WinTerminate (hab);
  88.         return 1;
  89.     }
  90.  
  91.  
  92.     /* Load the setup dialog DLL from the MMOS directory                    */
  93.     if ((rc = DosScanEnv (env, &pmmbase)) != 0)
  94.     {
  95.         WinMessageBox (HWND_DESKTOP, HWND_DESKTOP,
  96.                        (PSZ)"Unable to locate the multimedia information",
  97.                        (PSZ)WTV_NAME,
  98.                        0, MB_OK | MB_INFORMATION);
  99.  
  100.         WinDestroyMsgQueue (hmq);
  101.         WinTerminate (hab);
  102.         return 1;
  103.     }
  104.  
  105. #ifdef DEBUG
  106.     WinMessageBox (HWND_DESKTOP, HWND_DESKTOP, (PSZ)pmmbase, (PSZ)WTV_NAME,
  107.                    0, MB_OK | MB_INFORMATION);
  108. #endif
  109.  
  110.     if (p = strstr (pmmbase, ";"))
  111.         *p = '\0';
  112.  
  113.     sprintf (mod_txt, "%s\\DLL\\%5.5sNB.DLL", pmmbase, argv[1]);
  114.     if ((rc = DosLoadModule (txt, sizeof (txt), mod_txt, &HmodInsert)) != 0)
  115.     {
  116.         sprintf (txt, "DosLoadModule <%s> - %ld", mod_txt, rc);
  117.  
  118.         WinMessageBox (HWND_DESKTOP, HWND_DESKTOP,
  119.                        (PSZ)txt, (PSZ)WTV_NAME, 0, MB_OK | MB_ERROR);
  120.  
  121.         WinDestroyMsgQueue (hmq);
  122.         WinTerminate (hab);
  123.         return 1;
  124.     }
  125.  
  126.     if ((rc = DosQueryProcAddr (HmodInsert, 0L, InsertName, &InsertAddr)) != 0)
  127.     {
  128.         sprintf (txt, "DosQueryProcAddr (InsertPage) - %ld", rc);
  129.  
  130.         WinMessageBox (HWND_DESKTOP, HWND_DESKTOP,
  131.                        (PSZ)txt, (PSZ)WTV_NAME, 0, MB_OK | MB_ERROR);
  132.  
  133.         WinDestroyMsgQueue (hmq);
  134.         WinTerminate (hab);
  135.         return 1;
  136.     }
  137.  
  138.     /* Now load the remote control into the program                         */
  139.     sprintf (mod_txt, "%s\\DLL\\PMTV2REM.DLL", pmmbase);
  140.     if ((rc = DosLoadModule (txt, sizeof (txt), mod_txt, &HmodRemote)) != 0)
  141.     {
  142.         sprintf (txt, "DosLoadModule (PMTV2REM.DLL) - %ld", rc);
  143.  
  144.         WinMessageBox (HWND_DESKTOP, HWND_DESKTOP,
  145.                        (PSZ)txt, (PSZ)WTV_NAME, 0, MB_OK | MB_INFORMATION);
  146.  
  147.         WinDestroyMsgQueue (hmq);
  148.         WinTerminate (hab);
  149.         return 1;
  150.     }
  151.  
  152.     if ((rc = DosQueryProcAddr (HmodRemote, 0L, RemoteName, &RemoteAddr)) != 0)
  153.     {
  154.         sprintf (txt, "DosQueryProcAddr (RemoteDlgProc) - %ld", rc);
  155.  
  156.         WinMessageBox (HWND_DESKTOP, HWND_DESKTOP,
  157.                        (PSZ)txt, (PSZ)WTV_NAME, 0, MB_OK | MB_INFORMATION);
  158.  
  159.         WinDestroyMsgQueue (hmq);
  160.         WinTerminate (hab);
  161.         return 1;
  162.     }
  163.  
  164.     if (DiveRegister (hab) == FALSE)
  165.     {
  166.         WinDestroyMsgQueue (hmq);
  167.         WinTerminate (hab);
  168.         DosExit (EXIT_PROCESS, 1);
  169.         return 1;
  170.     }
  171.  
  172.     /* While there are still messages, dispatch them.                       */
  173.     while (WinGetMsg (hab, &qmsg, 0, 0, 0))
  174.         WinDispatchMsg (hab, &qmsg);
  175.  
  176. #ifdef DEBUG
  177.     WinMessageBox (HWND_DESKTOP, HWND_DESKTOP,
  178.                    (PSZ)"Application closing down",
  179.                    (PSZ)WTV_NAME, 0, MB_OK | MB_INFORMATION);
  180. #endif
  181.  
  182.     DiveStop ();
  183.  
  184.     /* Process for termination                                              */
  185.     WinDestroyMsgQueue (hmq);
  186.     WinTerminate (hab);
  187.  
  188.     DosExit (EXIT_PROCESS, 0);
  189.     return 0;
  190. }
  191.  
  192.  
  193. void remote_open (MOUSEPOS mousepos)
  194. {
  195.        /* if (RemOpen)    */
  196.        /*     return;     */
  197.         HwndRemote = WinLoadDlg (HWND_DESKTOP, HWND_DESKTOP, (PFNWP)RemoteAddr,
  198.                                  HmodRemote, IDD_REM, (PVOID)&mousepos);
  199. }
  200.