1 | /****************************************************************************** |
---|
2 | * SAGE - Scalable Adaptive Graphics Environment |
---|
3 | * |
---|
4 | * Copyright (C) 2004 Electronic Visualization Laboratory, |
---|
5 | * University of Illinois at Chicago |
---|
6 | * |
---|
7 | * All rights reserved. |
---|
8 | * |
---|
9 | * Redistribution and use in source and binary forms, with or without |
---|
10 | * modification, are permitted provided that the following conditions are met: |
---|
11 | * |
---|
12 | * * Redistributions of source code must retain the above copyright |
---|
13 | * notice, this list of conditions and the following disclaimer. |
---|
14 | * * Redistributions in binary form must reproduce the above |
---|
15 | * copyright notice, this list of conditions and the following disclaimer |
---|
16 | * in the documentation and/or other materials provided with the distribution. |
---|
17 | * * Neither the name of the University of Illinois at Chicago nor |
---|
18 | * the names of its contributors may be used to endorse or promote |
---|
19 | * products derived from this software without specific prior written permission. |
---|
20 | * |
---|
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
---|
22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
---|
23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
---|
24 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
---|
25 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
---|
26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
---|
27 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
---|
28 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
---|
29 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
---|
30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
---|
31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
32 | * |
---|
33 | * Direct questions, comments etc about SAGE to http://www.evl.uic.edu/cavern/forum/ |
---|
34 | * |
---|
35 | *****************************************************************************/ |
---|
36 | |
---|
37 | #ifndef SVC_INPUT_1394_H |
---|
38 | #define SVC_INPUT_1394_H |
---|
39 | |
---|
40 | #include <stdio.h> |
---|
41 | #include "libiec61883/iec61883.h" |
---|
42 | #include <sys/select.h> |
---|
43 | #include <string.h> |
---|
44 | #include <stdlib.h> |
---|
45 | #include <pthread.h> |
---|
46 | #include "SVC_input_module.h" |
---|
47 | #include "SVC_output_module.h" |
---|
48 | #include "SVC_decode_mpeg2.h" |
---|
49 | #include "SVC_buffer_manager.h" |
---|
50 | |
---|
51 | typedef void (*CAPTURE_CALLBACK)(raw1394handle_t handle, void* obj, int channe); |
---|
52 | |
---|
53 | class SVC_input_1394 : public SVC_input_module |
---|
54 | { |
---|
55 | public: |
---|
56 | SVC_input_1394(); |
---|
57 | void process(); |
---|
58 | void init(int codec, int color_mode, char* o_addr, int o_port); |
---|
59 | static int write_frame_dv (unsigned char *data, int len, int complete, void *callback_data); |
---|
60 | static int write_packet_mpeg2 (unsigned char *data, int len, unsigned int dropped, void *callback_data); |
---|
61 | static void dv_receive( raw1394handle_t handle, void* obj, int channel); |
---|
62 | static void mpeg2_receive (raw1394handle_t handle, void *obj, int channel); |
---|
63 | int insert2buffer(unsigned char* data, int len); |
---|
64 | static void* input_thread(void* obj); |
---|
65 | void input_thread2(); |
---|
66 | void select_decoder(int codec); |
---|
67 | int insert2buffer(unsigned char* data, long len); |
---|
68 | void setOutput(SVC_output_module* output); |
---|
69 | void stop(); |
---|
70 | void run(); |
---|
71 | void join(); |
---|
72 | void setBuffer(SVC_buffer*); |
---|
73 | static void decode_output_callback(void* output_obj, uint8_t * const * buf, void * id, int width, int height); |
---|
74 | SVC_decode_mpeg2* m_decode_mpeg2; |
---|
75 | void set_imagesize(int width, int height); |
---|
76 | void decode_ouput(uint8_t * const * buf); |
---|
77 | int m_codec; |
---|
78 | SVC_output_module* m_output_module; |
---|
79 | |
---|
80 | private: |
---|
81 | raw1394handle_t handle; |
---|
82 | CAPTURE_CALLBACK m_capture_callback; |
---|
83 | pthread_t inputThreadID; |
---|
84 | SVC_buffer* m_svc_buffer; |
---|
85 | int m_byte_pixel; |
---|
86 | int m_pid; |
---|
87 | int m_color_mode; |
---|
88 | int m_width; |
---|
89 | int m_height; |
---|
90 | char* m_output_addr; |
---|
91 | int m_output_port; |
---|
92 | |
---|
93 | }; |
---|
94 | |
---|
95 | |
---|
96 | #endif |
---|