1 #ifndef EMOTION_GENERIC_PLUGIN_H
2 #define EMOTION_GENERIC_PLUGIN_H
13 #include <semaphore.h>
16 #define DEFAULTWIDTH 320
17 #define DEFAULTHEIGHT 240
18 #define DEFAULTPITCH 4
20 typedef enum _Emotion_Generic_Cmd Emotion_Generic_Cmd;
21 typedef enum _Emotion_Generic_Result Emotion_Generic_Result;
22 typedef struct _Emotion_Generic_Video_Frame Emotion_Generic_Video_Frame;
23 typedef struct _Emotion_Generic_Video_Shared Emotion_Generic_Video_Shared;
25 enum _Emotion_Generic_Cmd
27 EM_CMD_INIT = 0, // param: shared memory identifier (string)
28 EM_CMD_PLAY, // param: position (float)
29 EM_CMD_STOP, // param: none
30 EM_CMD_FILE_SET, // param: filename (string)
31 EM_CMD_FILE_SET_DONE, // param: success (int)
32 EM_CMD_FILE_CLOSE, // param: none
33 EM_CMD_POSITION_SET, // param: position (float)
34 EM_CMD_SPEED_SET, // param: speed (float)
35 EM_CMD_AUDIO_MUTE_SET, // param: muted (int)
36 EM_CMD_VIDEO_MUTE_SET, // param: muted (int)
37 EM_CMD_SPU_MUTE_SET, // param: muted (int)
38 EM_CMD_VOLUME_SET, // param: volume (float)
39 EM_CMD_AUDIO_TRACK_SET, // param: track id (int)
40 EM_CMD_VIDEO_TRACK_SET, // param: track id (int)
41 EM_CMD_SPU_TRACK_SET, // param: track id (int)
45 enum _Emotion_Generic_Result
47 EM_RESULT_INIT = 0, // param: none
48 EM_RESULT_FILE_SET, // param: none
49 EM_RESULT_FILE_SET_DONE, // param: success (int)
50 EM_RESULT_PLAYBACK_STOPPED, // param: none
51 EM_RESULT_FILE_CLOSE, // param: none
52 EM_RESULT_FRAME_NEW, // param: none
53 EM_RESULT_FRAME_SIZE, // param: int, int (width, height)
54 EM_RESULT_LENGTH_CHANGED, // param: float
55 EM_RESULT_POSITION_CHANGED, // param: float
56 EM_RESULT_SEEKABLE_CHANGED, // param: int
57 EM_RESULT_AUDIO_TRACK_INFO, // param: current track, track count, track_id, track_name, track_id2, track_name2, ...
58 EM_RESULT_VIDEO_TRACK_INFO, // param: current track, track count, track_id, track_name, track_id2, track_name2, ...
59 EM_RESULT_SPU_TRACK_INFO, // param: current spu, spu count, spu_id, spu_name, spu_id2, spu_name2, ...
60 // (int, int, int, string, int, string, ...)
61 EM_RESULT_META_INFO, // param: title, artist, album, year, genre, comments, disc id, count (all int)
65 /* structure for frames 2 buffers to keep integrity */
66 struct _Emotion_Generic_Video_Frame
68 unsigned char *frames[3];
71 /* structure for frames 2 buffers to keep integrity */
72 struct _Emotion_Generic_Video_Shared
79 * - "emotion" is the frame from where the Emotion process is reading pixels.
80 * The player shouldn't touch this frame.
81 * - "player" is the frame where the slayer process is writing pixels.
82 * The emotion process shouldn't touch this frame.
83 * - "last" is the last frame that was rendered by the player. Emotion will
84 * use this frame the next time it will fetch pixels to Evas.
85 * - "next" is the unused frame. The player currently using the "player"
86 * should, after finishing this frame, set "last" to "player", and "player"
87 * to "next", and finally "next" to "last" so this operation can be done
88 * many times in case that Emotion does not request pixels fast enough.
101 emotion_generic_shm_get(const char *shmname, Emotion_Generic_Video_Shared **vs, Emotion_Generic_Video_Frame *vf)
105 Emotion_Generic_Video_Shared *t_vs;
107 shmfd = shm_open(shmname, O_RDWR, 0777);
110 fprintf(stderr, "player: could not open shm: %s\n", shmname);
111 fprintf(stderr, "player: %s\n", strerror(errno));
115 t_vs = mmap(NULL, sizeof(*t_vs), PROT_READ|PROT_WRITE, MAP_SHARED, shmfd, 0);
116 if (t_vs == MAP_FAILED)
118 fprintf(stderr, "player: could not map shared memory.\n");
119 fprintf(stderr, "player: %s\n", strerror(errno));
123 munmap(t_vs, sizeof(*t_vs));
124 t_vs = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_SHARED, shmfd, 0);
125 if (t_vs == MAP_FAILED)
127 fprintf(stderr, "player: could not map shared memory.\n");
128 fprintf(stderr, "player: %s\n", strerror(errno));
132 vf->frames[0] = (unsigned char *)t_vs + sizeof(*t_vs);
133 vf->frames[1] = (unsigned char *)t_vs + sizeof(*t_vs) + t_vs->height * t_vs->width * t_vs->pitch;
134 vf->frames[2] = (unsigned char *)t_vs + sizeof(*t_vs) + 2 * t_vs->height * t_vs->width * t_vs->pitch;
142 emotion_generic_shm_free(Emotion_Generic_Video_Shared *vs)
144 munmap(vs, vs->size);
147 #endif // EMOTION_GENERIC_PLUGIN_H