1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
|
<?php
/**
* @file
* Provides installation schema for video.module
* @author Heshan Wanigasooriya <heshan@heidisoft.com>
*
*/
/**
* Implementation of hook_schema().
*/
function video_schema() {
// video files
$schema['video_files'] = array(
'description' => 'Store video transcoding queue.',
'fields' => array(
'vid' => array(
'description' => t('Video id, the primary identifier'),
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'fid' => array(
'description' => 'The {file_managed}.fid being referenced in this field.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'nid' => array(
'description' => 'The {node}.nid being referenced in this field.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'status' => array(
'description' => 'Status of the transcoding, possible values are 1, 5, 10, 20',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'dimensions' => array(
'description' => 'The dimensions of the output video.',
'type' => 'varchar',
'length' => '255',
'default' => '',
),
'started' => array(
'description' => t('Start timestamp of transcodings'),
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'completed' => array(
'description' => 'Transcoding completed timestamp',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'data' => array(
'type' => 'blob',
'not null' => FALSE,
'size' => 'big',
'serialize' => TRUE,
'description' => 'A serialized array of converted files.
Use of this field is discouraged and it will likely disappear in a future version of Drupal.',
),
),
'indexes' => array(
'status' => array('status'),
'file' => array('fid'),
),
'primary key' => array('vid'),
);
// video preset
$schema['video_preset'] = array(
'description' => 'The preset table.',
'fields' => array(
'pid' => array(
'description' => 'The primary identifier for a video preset.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'name' => array(
'description' => 'The name of this preset.',
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
),
'description' => array(
'description' => 'A brief description of this preset.',
'type' => 'text',
'size' => 'medium',
'translatable' => TRUE,
),
'settings' => array(
'type' => 'blob',
'not null' => FALSE,
'size' => 'big',
'serialize' => TRUE,
'description' => 'Serialized preset settings that do not warrant a dedicated column.
Use of this field is discouraged and it will likely disappear in a future version of Drupal.',
),
),
'unique keys' => array(
'name' => array('name'),
),
'primary key' => array('pid'),
);
// video thumbnails
$schema['video_thumbnails'] = array(
'description' => 'The video thumbnails table.',
'fields' => array(
'vid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'Foreign Key {video_files}.fid.',
),
'thumbnails' => array(
'type' => 'blob',
'not null' => FALSE,
'size' => 'big',
'serialize' => TRUE,
'description' => 'Serialized array of thumbnails data.
Use of this field is discouraged and it will likely disappear in a future version of Drupal.',
),
),
'indexes' => array(
'thumbnail' => array('vid'),
),
'foreign keys' => array(
'thumbnails' => array(
'table' => 'video_files',
'columns' => array('vid' => 'vid'),
),
),
);
return $schema;
}
/**
* Implements hook_field_schema().
*/
function video_field_schema($field) {
return array(
'columns' => array(
'fid' => array(
'description' => 'The {file_managed}.fid being referenced in this field.',
'type' => 'int',
'not null' => FALSE,
'unsigned' => TRUE,
),
'thumbanail' => array(
'description' => 'The {file_managed}.fid being referenced for video thumbanil.',
'type' => 'int',
'not null' => FALSE,
'unsigned' => TRUE,
),
'player_dimensions' => array(
'description' => "Video dimention for the video player.",
'type' => 'varchar',
'length' => 32,
'not null' => FALSE,
)
),
'indexes' => array(
'fid' => array('fid'),
),
'foreign keys' => array(
'fid' => array(
'table' => 'file_managed',
'columns' => array('fid' => 'fid'),
),
),
);
}
/**
* Implementation of hook_install().
*/
function video_install() {
// Create the videos directory and ensure it's writable.
$directory = file_default_scheme() . '://videos';
file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
}
/**
* Implementation of hook_uninstall().
*/
function video_uninstall() {
drupal_uninstall_schema('video');
// Remove the video directory and generated images.
file_unmanaged_delete_recursive(file_default_scheme() . '://videos');
}
|