transport.h

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2002 Paul Davis
00003     Copyright (C) 2003 Jack O'Quin
00004     
00005     This program is free software; you can redistribute it and/or modify
00006     it under the terms of the GNU Lesser General Public License as published by
00007     the Free Software Foundation; either version 2.1 of the License, or
00008     (at your option) any later version.
00009     
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013     GNU Lesser General Public License for more details.
00014     
00015     You should have received a copy of the GNU Lesser General Public License
00016     along with this program; if not, write to the Free Software 
00017     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00018 
00019 */
00020 
00021 #ifndef __jack_transport_h__
00022 #define __jack_transport_h__
00023 
00024 #ifdef __cplusplus
00025 extern "C" {
00026 #endif
00027 
00028 #include <jack/types.h>
00029 
00030 #ifndef 
00031 #ifdef __GNUC__
00032 /*  needs to be a macro which
00033    expands into a compiler directive. The directive must
00034    tell the compiler to arrange the preceding structure
00035    declaration so that it is packed on byte-boundaries rather 
00036    than use the natural alignment of the processor and/or
00037    compiler.
00038 */
00039 #define  __attribute__((__packed__))
00040 #else
00041 /* Add other things here for non-gcc platforms */
00042 #endif
00043 #endif
00044 
00045 
00049 typedef enum {
00050 
00051         /* the order matters for binary compatibility */
00052         JackTransportStopped = 0,       
00053         JackTransportRolling = 1,       
00054         JackTransportLooping = 2,       
00055         JackTransportStarting = 3       
00057 } jack_transport_state_t;
00058 
00059 typedef uint64_t jack_unique_t;         
00064 typedef enum {
00065 
00066         JackPositionBBT =         0x10, 
00067         JackPositionTimecode =    0x20, 
00068         JackBBTFrameOffset =      0x40, 
00069         JackAudioVideoRatio =     0x80, 
00070         JackVideoFrameOffset =   0x100  
00071 } jack_position_bits_t;
00072 
00074 #define JACK_POSITION_MASK (JackPositionBBT|JackPositionTimecode|JackBBTFrameOffset|JackAudioVideoRatio|JackVideoFrameOffset)
00075 #define EXTENDED_TIME_INFO
00076 
00080 typedef struct {
00081     
00082     /* these four cannot be set from clients: the server sets them */
00083     jack_unique_t       unique_1;       
00084     jack_time_t         usecs;          
00085     jack_nframes_t      frame_rate;     
00086     jack_nframes_t      frame;          
00088     jack_position_bits_t valid;         
00090     /* JackPositionBBT fields: */
00091     int32_t             bar;            
00092     int32_t             beat;           
00093     int32_t             tick;           
00094     double              bar_start_tick;            
00095 
00096     float               beats_per_bar;  
00097     float               beat_type;      
00098     double              ticks_per_beat;
00099     double              beats_per_minute;
00100 
00101     /* JackPositionTimecode fields:     (EXPERIMENTAL: could change) */
00102     double              frame_time;     
00103     double              next_time;      
00106     /* JackBBTFrameOffset fields: */
00107     jack_nframes_t      bbt_offset;     
00122     /* JACK video positional data (experimental) */
00123 
00124     float               audio_frames_per_video_frame; 
00131     jack_nframes_t      video_offset;   
00138     /* For binary compatibility, new fields should be allocated from
00139      * this padding area with new valid bits controlling access, so
00140      * the existing structure size and offsets are preserved. */
00141     int32_t             padding[7];
00142 
00143     /* When (unique_1 == unique_2) the contents are consistent. */
00144     jack_unique_t       unique_2;       
00146 }  jack_position_t;
00147 
00169 int  jack_release_timebase (jack_client_t *client);
00170 
00192 typedef int  (*JackSyncCallback)(jack_transport_state_t state,
00193                                  jack_position_t *pos,
00194                                  void *arg);
00195 
00216 int  jack_set_sync_callback (jack_client_t *client,
00217                              JackSyncCallback sync_callback,
00218                              void *arg);
00219 
00237 int  jack_set_sync_timeout (jack_client_t *client,
00238                             jack_time_t timeout);
00239 
00269 typedef void (*JackTimebaseCallback)(jack_transport_state_t state,
00270                                      jack_nframes_t nframes, 
00271                                      jack_position_t *pos,
00272                                      int new_pos,
00273                                      void *arg);
00274 
00300 int  jack_set_timebase_callback (jack_client_t *client,
00301                                  int conditional,
00302                                  JackTimebaseCallback timebase_callback,
00303                                  void *arg);
00304 
00321 int  jack_transport_locate (jack_client_t *client,
00322                             jack_nframes_t frame);
00323 
00339 jack_transport_state_t jack_transport_query (const jack_client_t *client,
00340                                              jack_position_t *pos);
00341 
00349 jack_nframes_t jack_get_current_transport_frame (const jack_client_t *client);
00350                                                  
00367 int  jack_transport_reposition (jack_client_t *client,
00368                                 jack_position_t *pos);
00369 
00381 void jack_transport_start (jack_client_t *client);
00382 
00391 void jack_transport_stop (jack_client_t *client);
00392 
00395 /*********************************************************************
00396  * The following interfaces are DEPRECATED.  They are only provided
00397  * for compatibility with the earlier JACK transport implementation.
00398  *********************************************************************/
00399 
00405 typedef enum {
00406 
00407         JackTransportState =    0x1,    
00408         JackTransportPosition = 0x2,    
00409         JackTransportLoop =     0x4,    
00410         JackTransportSMPTE =    0x8,    
00411         JackTransportBBT =      0x10    
00413 } jack_transport_bits_t;
00414 
00421 typedef struct {
00422     
00423     /* these two cannot be set from clients: the server sets them */
00424 
00425     jack_nframes_t frame_rate;          
00426     jack_time_t    usecs;               
00428     jack_transport_bits_t  valid;       
00429     jack_transport_state_t transport_state;         
00430     jack_nframes_t         frame;
00431     jack_nframes_t         loop_start;
00432     jack_nframes_t         loop_end;
00433 
00434     long           smpte_offset;        
00435     float          smpte_frame_rate;    
00437     int            bar;
00438     int            beat;
00439     int            tick;
00440     double         bar_start_tick;            
00441 
00442     float          beats_per_bar;
00443     float          beat_type;
00444     double         ticks_per_beat;
00445     double         beats_per_minute;
00446 
00447 } jack_transport_info_t;
00448         
00461 void jack_get_transport_info (jack_client_t *client,
00462                               jack_transport_info_t *tinfo);
00463 
00471 void jack_set_transport_info (jack_client_t *client,
00472                               jack_transport_info_t *tinfo);
00473 
00474 #ifdef __cplusplus
00475 }
00476 #endif
00477 
00478 #endif /* __jack_transport_h__ */
00479