home *** CD-ROM | disk | FTP | other *** search
/ Resource Library: Multimedia / Resource Library: Multimedia.iso / maestro / source / vcredit / vcrdtprv.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-15  |  9.0 KB  |  299 lines

  1. /*
  2.  * Copyright (c) 1990, 1991 Stanford University
  3.  *
  4.  * Permission to use, copy, modify, and distribute this software and 
  5.  * its documentation for any purpose is hereby granted without fee, provided
  6.  * that (i) the above copyright notices and this permission notice appear in
  7.  * all copies of the software and related documentation, and (ii) the name
  8.  * Stanford may not be used in any advertising or publicity relating to
  9.  * the software without the specific, prior written permission of
  10.  * Stanford.
  11.  * 
  12.  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
  13.  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
  14.  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
  15.  *
  16.  * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
  17.  * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES
  18.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT
  19.  * ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY,
  20.  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  21.  * SOFTWARE.
  22.  */
  23.  
  24. /* $Header: /Source/Media/collab/vcrEdit/RCS/vcrEditPreview.c,v 0.17 92/09/29 18:07:11 drapeau Exp $ */
  25. /* $Log:    vcrEditPreview.c,v $
  26.  * Revision 0.17  92/09/29  18:07:11  drapeau
  27.  * Minor cosmetic changes to enhance readability and ANSI compliance.
  28.  * 
  29.  * Revision 0.16  92/05/14  00:06:16  drapeau
  30.  * * When previewing an edit, no longer disconnects from and
  31.  *   reconnects with the Port Manager.  Previously, this was done because
  32.  *   of the way the Port Manager tested its communications link with
  33.  *   applications (it did so by trying to send a SenderPing() message,
  34.  *   which would block until the receiving application could reply to
  35.  *   the message).  Now, the Port Manager simply tries to create a
  36.  *   new Sender, which does not require a reply from the receiving application.
  37.  * * Made a number of formatting changes, to conform to coding standards.
  38.  * 
  39.  * Revision 0.15  91/09/26  12:34:14  lim
  40.  * Did casting for xv_get's, etc.
  41.  * 
  42.  * Revision 0.14  91/08/24  18:00:10  lim
  43.  * Implemented PrintDiagnostics. With command line flag '-d', the 
  44.  * app will launch such that it prints all diag messages.
  45.  * 
  46.  * Revision 0.13  91/08/16  12:35:54  lim
  47.  * PlayEdit() will call SenderDisconnectFromPortMgr() and SenderConnectWith
  48.  * PortMgr() if it is a search (start == end).
  49.  * 
  50.  * Revision 0.12  91/08/08  16:34:28  lim
  51.  * 1. Added instance pointer to each public videoObject function call.
  52.  * 2. speedStg is now an array of integers.
  53.  * 3. Duration depends on speed of edit.
  54.  * 
  55.  * Revision 0.11  91/07/20  11:44:16  lim
  56.  * Added PlayEdit, which sets audio and speed before calling
  57.  * DevPlayFromTo.
  58.  * 
  59.  * 
  60.  * Revision 0.10  91/07/16  16:17:20  lim
  61.  * Initial revision.
  62.  *  */
  63.  
  64. #include "vcrEdit.h"
  65. static char prevrcsid[] = "$Header: /Source/Media/collab/vcrEdit/RCS/vcrEditPreview.c,v 0.17 92/09/29 18:07:11 drapeau Exp $";
  66.  
  67. /*     EDIT PREVIEW FUNCTIONS (POPUP WINDOW 3)    */
  68.  
  69. /* Plays edit from `start' to `end' using correct settings' */
  70. void PlayEdit(int start, int end)
  71. {
  72.   int speed;
  73.  
  74.   DevSetAudio(myVideo, 3 - currentAudio);                /* Set audio */
  75.   speed =  xv_get(vcrEdit_editPopup->editSpeedTxt, PANEL_VALUE);
  76.   DevPlayFromTo(myVideo, start, end, speed);                /* Play segment at set speed */
  77.   return;
  78. }                                    /* end function PlayEdit */
  79.  
  80.  
  81.  
  82. /*
  83.  * Menu handler for `previewMenu (Play entire edit)'.
  84.  * Default : Play the current selection from start to end.
  85.  */
  86. Menu_item
  87.   PreviewStartEnd(Menu_item item, Menu_generate op)
  88. {
  89.   int result;
  90.   int start;
  91.   int starthr;
  92.   int startmin; 
  93.   int startsec; 
  94.   int startfr;
  95.   int end;
  96.   int endhr;
  97.   int endmin;
  98.   int endsec;
  99.   int endfr;
  100.   
  101.   switch (op) 
  102.   {
  103.    case MENU_DISPLAY:
  104.     break;
  105.     
  106.    case MENU_DISPLAY_DONE:
  107.     break;
  108.     
  109.    case MENU_NOTIFY:
  110.     if (!SetDuration())                            /* Get start and end frames */
  111.       return item;
  112.     startfr = atoi((char*) xv_get(vcrEdit_editPopup->editStartTxt4, 
  113.                   PANEL_VALUE));
  114.     endfr = atoi((char*) xv_get(vcrEdit_editPopup->editEndTxt4, PANEL_VALUE));
  115.     
  116.     starthr = atoi((char*) xv_get(vcrEdit_editPopup->editStartTxt1, PANEL_VALUE));
  117.     startmin = atoi((char*) xv_get(vcrEdit_editPopup->editStartTxt2, PANEL_VALUE));
  118.     startsec = atoi((char*) xv_get(vcrEdit_editPopup->editStartTxt3, PANEL_VALUE));
  119.     start = ConvertToAddress(starthr, startmin, startsec, startfr);
  120.     
  121.     endhr = atoi((char*) xv_get(vcrEdit_editPopup->editEndTxt1, PANEL_VALUE));
  122.     endmin = atoi((char*) xv_get(vcrEdit_editPopup->editEndTxt2, PANEL_VALUE));
  123.     endsec = atoi((char*) xv_get(vcrEdit_editPopup->editEndTxt3, PANEL_VALUE));
  124.     end = ConvertToAddress(endhr, endmin, endsec, endfr);
  125.     
  126.     result = CheckSelection(start, end);                /* Check if selection is valid */
  127.     if (result == -1)
  128.       return(item);
  129.     PlayEdit(start, end);
  130.     break;
  131.     
  132.    case MENU_NOTIFY_DONE:
  133.     break;
  134.   }
  135.   return item;
  136. }                                    /* end function PreviewStartEnd */
  137.  
  138.  
  139. /*
  140.  * Notify callback function for `previewPlayFirstButton'.
  141.  * Play the first x seconds of the current selection.
  142.  */
  143. void
  144.   PreviewStart(Panel_item item, Event* event)
  145. {
  146.   int start; 
  147.   int end; 
  148.   int duration;
  149.   int result;
  150.   int starthr; 
  151.   int startmin; 
  152.   int startsec;
  153.   int startfr;
  154.   int endhr; 
  155.   int endmin; 
  156.   int endsec; 
  157.   int endfr;
  158.   int speed;
  159.   
  160.   starthr = atoi((char*) xv_get(vcrEdit_editPopup->editStartTxt1,   /* Get start and end frames */
  161.                 PANEL_VALUE));
  162.   startmin = atoi((char*) xv_get(vcrEdit_editPopup->editStartTxt2,
  163.                  PANEL_VALUE));
  164.   startsec = atoi((char*) xv_get(vcrEdit_editPopup->editStartTxt3,
  165.                  PANEL_VALUE));
  166.   startfr = atoi((char*) xv_get(vcrEdit_editPopup->editStartTxt4,
  167.                 PANEL_VALUE));
  168.   start = ConvertToAddress(starthr, startmin, startsec, startfr);
  169.   
  170.   endhr = atoi((char*) xv_get(vcrEdit_editPopup->editEndTxt1, PANEL_VALUE));
  171.   endmin = atoi((char*) xv_get(vcrEdit_editPopup->editEndTxt2, PANEL_VALUE));
  172.   endsec = atoi((char*) xv_get(vcrEdit_editPopup->editEndTxt3, PANEL_VALUE));
  173.   endfr = atoi((char*) xv_get(vcrEdit_editPopup->editEndTxt4, PANEL_VALUE));
  174.   end = ConvertToAddress(endhr, endmin, endsec, endfr);
  175.   
  176.   speed = xv_get(vcrEdit_editPopup->editSpeedTxt, PANEL_VALUE);
  177.   result = CheckSelection(start, end);                    /* Check if selection is valid */
  178.   if (result == -1)
  179.     return; 
  180.   duration = xv_get(vcrEdit_previewPopup->previewPlayFirstTxt,        /* Get the duration to be played */
  181.             PANEL_VALUE);
  182.   if (end > (start + duration*speed))
  183.     end = start + duration*speed;
  184.   PlayEdit(start, end);
  185. }                                    /* end function PreviewStart */
  186.  
  187.  
  188.  
  189. /*
  190.  * Notify callback function for `previewPlayFirstTxt'.
  191.  */
  192. Panel_setting
  193. PreviewStartTxt(item, event)
  194.      Panel_item    item;
  195.      Event        *event;
  196. {
  197.   
  198.   if (event_action(event) != '\r')
  199.     return PANEL_NONE;
  200.   
  201.   if (search == 1)
  202.     search = 0;
  203.   else {
  204.     PreviewStart(item, event);
  205.     search = 1;
  206.   }
  207. }
  208.  
  209.  
  210.  
  211. /* Notify callback function for `previewPlayLastButton'.
  212.  * Play the last x seconds of the current selection.
  213.  */
  214. void
  215.   PreviewEnd(item, event)
  216. Panel_item      item;
  217. Event           *event;
  218. {
  219.   int start;
  220.   int end;
  221.   int duration;
  222.   int result;
  223.   int starthr; 
  224.   int startmin;
  225.   int startsec; 
  226.   int startfr;
  227.   int endhr;
  228.   int endmin; 
  229.   int endsec; 
  230.   int endfr;
  231.   int speed;
  232.  
  233.   starthr = atoi((char*) xv_get(vcrEdit_editPopup->editStartTxt1,   /* Get start and end frame numbers */
  234.                 PANEL_VALUE));
  235.   startmin = atoi((char*) xv_get(vcrEdit_editPopup->editStartTxt2,
  236.                  PANEL_VALUE));
  237.   startsec = atoi((char*) xv_get(vcrEdit_editPopup->editStartTxt3,
  238.                  PANEL_VALUE));
  239.   startfr = atoi((char*) xv_get(vcrEdit_editPopup->editStartTxt4,
  240.                 PANEL_VALUE));
  241.   start = ConvertToAddress(starthr, startmin, startsec, startfr);
  242.   
  243.   endhr = atoi((char*) xv_get(vcrEdit_editPopup->editEndTxt1, PANEL_VALUE));
  244.   endmin = atoi((char*) xv_get(vcrEdit_editPopup->editEndTxt2, PANEL_VALUE));
  245.   endsec = atoi((char*) xv_get(vcrEdit_editPopup->editEndTxt3, PANEL_VALUE));
  246.   endfr = atoi((char*) xv_get(vcrEdit_editPopup->editEndTxt4, PANEL_VALUE));
  247.   end = ConvertToAddress(endhr, endmin, endsec, endfr);
  248.   
  249.   speed = xv_get(vcrEdit_editPopup->editSpeedTxt, PANEL_VALUE);
  250.   result = CheckSelection(start, end);                    /* Check if selection is valid */
  251.   if (result == -1)                            /* Error in selection */
  252.     return;
  253.   duration = xv_get (vcrEdit_previewPopup->previewPlayLastTxt,        /* Get the duration to be played */
  254.              PANEL_VALUE);
  255.   if (start < (end - duration*speed))
  256.     start = end - duration*speed;
  257.   
  258.   PlayEdit(start, end);
  259. }                                    /* end function PreviewEnd */
  260.  
  261.  
  262.  
  263.  
  264. /*
  265.  * Notify callback function for `previewPlayLastTxt'.
  266.  */
  267. Panel_setting
  268. PreviewEndTxt(item, event)
  269.      Panel_item    item;
  270.      Event        *event;
  271. {
  272.   
  273.   if (event_action(event) != '\r')
  274.     return PANEL_NONE;
  275.   
  276.   if (search == 1)
  277.     search = 0;
  278.   else {
  279.     PreviewEnd(item, event);
  280.     search = 1;
  281.   }
  282. }
  283.  
  284.  
  285. /*
  286.  * Notify callback function for `previewDoneButton'.
  287.  * Close the preview popup window
  288.  */
  289. void
  290. PreviewDone(item, event)
  291.      Panel_item      item;
  292.      Event           *event;
  293. {
  294.   xv_set(vcrEdit_previewPopup->previewPopup, FRAME_CMD_PUSHPIN_IN, FALSE, NULL);
  295.   xv_set(vcrEdit_previewPopup->previewPopup, XV_SHOW, FALSE, NULL);
  296.  
  297. }
  298.  
  299.