77c9dc1de91841e80f2d7c6d9bf4bba21e4aeae1
[platform/upstream/gstreamer.git] / markdown / contribute / index.md
1 ---
2 short-description: Contributing to GStreamer
3 ...
4
5 # Contributing to GStreamer
6
7 This document provides instructions and guidelines for submitting issues,
8 feature requests and patches to GStreamer. The following applies to all
9 these operations:
10
11 - Please use [freedesktop.org GitLab][gitlab] to perform any of the aforementioned
12   operations. You will need to create a freedesktop.org GitLab account if you
13   don't have one yet (yep, that's just how it is. Sorry for the inconvenience)
14   If you don't want to create a new account you should also be able to sign in
15   with a Google, GitHub or Twitter account.
16
17 ## How to File Issues and Request for Enhancements
18
19 ### Where to File Issues and Feature Requests
20
21 - Create a new issue if there is no existing report for this problem yet.
22   The GStreamer [bugs page][bugs] also has shortcuts for the major components
23   and simple search functionality if you'd like to browse or search for
24   existing issues, or use the [GitLab search bar for the GStreamer project][gitlab]
25   at the top of the page.
26
27 - If you are filing a feature request (i.e. anything that is not supposed to
28   work already, that is anything not an issue), please add the *Enhancement* label.
29   Feel free to add any other appropriate already existing labels. Please don't
30   create new labels just for your issue. This won't affect the way we prioritise
31   the issue, but it will make triaging easier for us. In particular, do not add
32   the *Blocker* label to an issue just because an issue is important to you.
33   This label should be added only by GStreamer maintainers.
34
35 - If your issue is about a specific plugin, element or utility library,
36   please prefix the issue summary with `element-name:`, `plugin-name:` or `lib:`
37   and keep the rest of the description as short and precise as possible.
38
39   Examples:
40
41    - `id3demux: fails to extract composer tags`
42    - `tsdemux: does not detect audio stream`
43    - `Internal flow error when playing matroska file`
44
45   This makes sure developers looking through the list of open issues or issue
46   notification mails can quickly identify what your issue is about. If your text
47   is too long and only contains fill words at the beginning, the important
48   information will be cut off and not show up in the list view or mail client.
49
50 - If you don't know which component to file the issue against, just pick the one
51   that seems the most likely to you, or file it against the gstreamer-project
52   component. If in doubt just pop into our IRC channel `#gstreamer` on the
53   [freenode IRC network](https://freenode.net), which you can connect to using
54   any IRC client application or the [freenode IRC webchat](https://webchat.freenode.net/?channels=%23gstreamer).
55   In any case, if it's not the right component someone will move the issue
56   once they have a better idea what the problem is and where it belongs.
57
58 - Please mention:
59
60    - what version of GStreamer you are using
61    - what operating system you are using (Windows, macOS, Linux)
62    - if you're on Linux, please mention your distro and distro version
63    - if this is on an embedded device please provide details
64
65 - Try to describe how the issue can be reproduced. If it is triggered by any
66   specific file, try to make the file available somewhere for download and
67   put the link into the issue. The easier it is for us to reproduce
68   the issue, the easier it is to fix it.
69
70 - If you experience a crash (that is: the application shuts down unexpectedly,
71   usually with a segfault or bus error or memory access violation or such),
72   please try to [obtain a stack trace][stack-trace]. If there are criticals
73   or warnings printed right before the crash, run with the environment variable
74   `G_DEBUG=fatal_warnings` set, then it will abort on the first warning, which
75   should hopefully give an indication to where the problem is. You can then
76   obtain a stack trace from where it aborts.
77
78 - If the application errors out, please provide a gst debug log. You can get
79   one by setting the `GST_DEBUG=*:6` environment variable, combined with
80   `GST_DEBUG_FILE=/tmp/dbg.log`. The resulting file might end up being very
81   large, so it's advisable to compress it with `xz -9 /tmp/dbg.log` before
82   sharing. You may also be asked to provide debug logs for specific debug
83   categories rather than everything (`*:6`).
84
85 [stack-trace]: https://wiki.gnome.org/Community/GettingInTouch/Bugzilla/GettingTraces/Details
86
87 ## How to Submit Patches
88
89 ### Where to Submit Patches
90
91 Patches need to be submitted through [GitLab][gitlab] in form of a
92 "Merge Request" (MR), which is the same as a "Pull Request" (PR)
93 in GitHub, and uses the same [workflow][gitlab-merge-request-workflow].
94
95 [gitlab-merge-request-workflow]: https://docs.gitlab.com/ce/user/project/merge_requests/index.html#overview
96
97 In order to submit a merge request you first need a personal fork of the
98 project / gstreamer module in question. To fork a module go to
99 the module in question (e.g. <https://gitlab.freedesktop.org/gstreamer/gstreamer>)
100 and hit the fork button. A new repository will be created in your user namespace
101 (<https://gitlab.freedesktop.org/$USERNAME/gstreamer>). You will be redirected
102 there automatically once the forking process is finished. For big repositories
103 the forking might take a few minutes.
104
105 Once this is done you can add your personal fork as new remote to your existing checkout with
106
107     git remote add my-personal-gitlab-fork git@gitlab.freedesktop.org:$USERNAME/gstreamer.git
108
109 Check with
110
111     git fetch my-personal-gitlab-fork
112
113 that it is accessible and working.
114
115 If you have not done so already, you may need to first
116 [set up SSH keys in your GitLab User Settings](https://gitlab.freedesktop.org/profile/keys).
117
118 Next, you make a git branch with one or more commits you want to submit
119 for review and merging. For that you will first need a local branch which
120 you can create with e.g.
121
122     git checkout -b fix-xyz
123
124 You can then push that branch to your personal fork git repository with
125
126     git push my-personal-gitlab-fork
127
128 You can use
129
130     git push --dry-run my-personal-gitlab-fork
131
132 for testing to see what would happen without actually doing anything yet.
133
134 After you have pushed the branch to your personal fork you will see a link
135 on the terminal with which you can create a merge request for the upstream
136 repository. You can also do this later by going to the
137 branch list of your personal repository at
138 <https://gitlab.freedesktop.org/$USERNAME/gstreamer/branches>
139 and then hitting the 'Merge Request' button when ready. This will open a new
140 page where you can enter a description of the changes you are submitting.
141
142 Couple of additional points:
143
144 - If you are submitting a Merge Request for an issue (or multiple issues) that
145   already exist, please add 'Fixes #123' to the commit message of one of your
146   commits, so that there is a cross-reference in GitLab and the issue will be
147   closed automatically when your Merge Request is merged.
148
149 - You do not have to file an issue to go with each Merge Request, it's fine
150   to just submit a Merge Request on its own.
151
152 - **Please enable the "Allow commits from members who can merge to the target branch"**
153   **checkbox when submitting merge requests** as otherwise maintainers can't
154   rebase your Merge Request when they want to merge it, which means they
155   won't be able to merge it.
156
157 - If your proposed changes are proposed for review but not ready to be merged
158   yet, please prefix the Merge Request title with `WIP:` for Work-in-Progress.
159   That will prevent us from inadvertently merging it and make clear its status.
160
161 - Please make sure the 'Author' field in your commit messages has your full and
162   proper name and e-mail address. You can check with e.g. `git log` or `gitk`.
163
164 - If your change is for an enhancement (anything that is not supposed to work
165   already, i.e. anything not a bug) or adds new API, please add the
166   *Enhancement* label. This won't affect the way we prioritise your issue,
167   but it does make triaging easier for us.
168
169 - If your Merge Request is against a specific plugin or element or utility library,
170   please prefix the Merge Request summary with `element-name:`, `plugin-name:`
171   or `lib:` and keep the rest of the description as short and precise as possible.
172
173   Examples:
174
175    - `id3demux: add support for WCOP frame`
176    - `riff: add RGB16 support`
177    - `playbin: detect if video-sink supports deinterlacing`
178    - `tests: rtprtx unit test is racy`
179
180   This makes sure developers looking through the list of open merge requests or
181   notification mails can quickly identify what your change is about. If your text
182   is too long and only contains fill words at the beginning, the important
183   information will be cut off and not show up in the list view or mail client.
184
185 - Make liberal use of the reference syntax available to help cross-linking
186   different issues and merge requests. e.g. `#100` references issue 100 in the
187   current module. `!100` references merge request 100 in the current project.
188   A complete list is available from [gitlab's documentation][special-md-references].
189
190 - Please create separate merge requests for separate issues and for different
191   modules. There is no golden rule when something counts as a separate issue,
192   please just use your best judgment.  If a merge request is related to another
193   merge request in another module please mention that in the description using
194   a gitlab reference as outlined above.  For example, if you have a change that
195   needs to be done in each module, one issue with one merge request per module
196   is fine. If there is an issue that requires related fixes in multiple elements
197   or libraries, please also feel free to put everything into one issue. If you
198   just happen to have multiple patches for us but they are not really related,
199   please put them in separate issues and merge requests. The main question is
200   if it makes sense to discuss and review these patches together or if they
201   could just as well be handled completely separately.
202
203 - Please do not send patches to the gstreamer-devel mailing list. Patches
204   submitted on the mailing list are most likely going to be ignored, overlooked,
205   or you will get a brief reply asking you to put them into gitlab. We do
206   not use the mailing list for patch review.
207
208 - Please do not send pull requests to our github mirror. They will be closed
209   automatically.
210
211 - Please do not attach patches to existing bugs on [GNOME Bugzilla][bugzilla]
212   If you want to reopen an already closed bug, let one of the developers know
213   and we will look into that on a case-by-case basis.
214
215 - Please do not attach patches to issues.
216
217
218 [special-md-references]: https://docs.gitlab.com/ee/user/markdown.html#special-gitlab-references
219 [bugzilla]: https://bugzilla.gnome.org/
220 [bugs]: https://gstreamer.freedesktop.org/bugs/
221 [gitlab]: https://gitlab.freedesktop.org/gstreamer
222
223 ### How to Prepare a Merge Request for Submission
224
225 If possible at all, you should prepare a merge request against a current git
226 checkout, ideally against the tip of the master branch.  The gitlab merge request
227 UI will contain information about whether the merge request can be applied to the
228 current code. If a merge request was prepared against an old commit and
229 does not apply any longer to master you may be asked to provide an updated
230 branch to merge.
231
232 If you have created a new plugin, please submit a merge request that adds it to
233 the gst-plugins-bad module, including `meson.build` modifications, and all new files.
234
235 #### Patch Format
236
237 The easiest way to create a merge request is to create one or more local commits
238 for your changes in a branch in a local git repository. This should be a git
239 clone checkout of your fork of the module in question.  To fork a module go to
240 the module in question (e.g. <https://gitlab.freedesktop.org/gstreamer/gstreamer>)
241 and hit the fork button.  A new repository will be created in your user namespace
242 and should be accessible as
243 <https://gitlab.freedesktop.org/$USERNAME/gstreamer>.
244 You should clone this repository with valid ssh credentials to be able to
245 automatically push code to your fork.
246
247 Once you have a git repository with the original code in it, you should create a
248 branch for your change. e.g. to create a branch and checkout:
249
250     git checkout -b topic-branch
251
252 Then you can make your modifications and create a local commit with e.g.
253
254     git commit path/to/file1.[ch]
255
256 This will pop up an editor where you can create your commit message. It should
257 look something like:
258
259     exampledemux: fix seeking without index in push mode
260
261     Without an index we would refuse to seek in push mode. Make
262     seeking without an index work by estimating the position
263     to seek to. It might not be 100% accurate, but better than
264     nothing.
265
266 Then exit the editor, and you should have a commit.
267
268 It's best to run `git add` or `git commit` on specific directories or files
269 instead of using `git commit -a`, as it's too easy to accidentally contaminate
270 a patch with changes that belong into it with `git commit -a`, in particular
271 changes to the `common` submodule.
272
273 You can check your commit(s) with `git show` or `git log -p` or using a GUI
274 such as `gitg` or `gitk`.
275
276 Make sure the author is correctly set to your full name and e-mail address.
277
278 If you haven't used git before, it would be a good idea to tell it who you are:
279
280     $ git config --global user.name "George S. Treamer"
281     $ git config --global user.email "george.s.treamer@example.com"
282
283 You can make changes to the last commit using:
284
285  - `git commit --amend` to fix up the commit message
286
287  - `git commit --amend --author='John You <john@you.com>'` to fix up the author
288
289  - `git add path/to/file1.[ch]; git commit --amend` to incorporate fixes
290     made to the files since the last commit (i.e. what shows up in `git diff`).
291     If you just want to add some of the changes, but not all of them you can
292     use `git add -p file.c`, then it will ask you for each individual change
293     whether you want to add it or leave it.
294
295 Once everything looks fine, push your branch to your local fork e.g. using
296
297     git push your-personal-gitlab-fork your-branch
298
299 This push will display a link to be able create a merge request from your branch.
300 Click this link and fill out the details of the merge request.  You can also
301 create a merge request from an existing branch. See the
302 [gitlab documentation][create-mr] for more details.
303
304 Please make sure your commits are as terse and precise as possible. Do not
305 include 'clean-ups' or non-functional changes, since they distract from the
306 real changes and make things harder to review, and also lower the chances that
307 the patch will still apply cleanly to the latest version in git. If you feel
308 there are things to clean up, please submit the clean-ups as a separate patch
309 that does not contain any functional changes.
310
311 Try to stick to the GStreamer indentation and coding style. There is a script
312 called [`gst-indent`][gst-indent] which you can run over your `.c` or `.cpp`
313 files if you want your code auto-indented before making the patch. The script
314 requires GNU indent to be installed already. Please do _not_ run `gst-indent` on
315 header files, our header file indentation is free-form. If you build GStreamer
316 from git, a local commit hook will be installed that checks if your commit
317 conforms to the required style (also using GNU indent).
318
319 [gst-indent]: https://gitlab.freedesktop.org/gstreamer/gstreamer/tree/master/tools/gst-indent
320 [create-mr]: https://docs.gitlab.com/ee/gitlab-basics/add-merge-request.html
321
322 ### Writing Good Commit Messages
323
324 Please take the time to write good and concise commit messages.
325
326 The first line of each commit message should be a short and concise summary
327 of the commit. If the commit applies to a specific subsystem, library, plugin
328 or element, prefix the message with the name of the component, for example:
329
330     oggdemux: fix granulepos query for the old theora bitstream
331
332 or
333
334     docs: add new stream API
335
336 or
337
338     tests: video: add unit test for converting RGB to XYZ colorspace
339
340 This should be a *summary* of the change and _not a description_ of the change.
341 Meaning: don't say *how* you did something but *what* you fixed, improved or
342 changed, what the most important practical *effect* of the change is. Example:
343
344     qtdemux: fix crash when doing reverse playback in push mode (good)
345
346 instead of
347
348     qtdemux: use signed integer to avoid counter underrun (bad)
349
350 The second line of the commit message should be empty.
351
352 The third and following lines should contain an extensive *description* and
353 *rationale* of the change made: what was changed, what was broken, how did it
354 get fixed, what bugs or issues does this fix? And most importantly: *why* was
355 something changed.
356
357 Trivial commits do not require a description, e.g. if you fix a memory leak
358 it's usually enough to just say that you fixed a leak. Maybe mention what was
359 leaked and perhaps also if it was an important leak or only happens in some
360 corner case error code path, but in any case there's no need to write a long
361 explanation why leaks are bad or why this needed fixing.
362
363 The important part is really what the reasoning behind the change is, since
364 that's what people want to know if they try to figure out twelve months later
365 why a line of code does what it does.
366
367 If the commit is related to any particular issues in gitlab, please add the
368 full issue URL at the end of the commit message.
369
370     https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/123
371
372 We do not use `Signed-off by:` lines in GStreamer, please create commits
373 without those.
374
375 ### After Submitting your Merge Request
376
377 Whenever you submit a new Merge Request, add a comment to an existing issue or
378 Merge Request, GitLab will send a notification e-mail to GStreamer
379 developers. This means that there is usually no need to advertise the fact that
380 you have done so in other forums such as on IRC or on the mailing list, unless
381 you have been asked to file an issue there, in which case it's nice to follow up
382 with the link to the issue.
383
384 Most of all, please be patient.
385
386 We try to review patches as quickly as possible, but there is such a high
387 turnaround of issues, merge requests and feature requests that it is not always
388 possible to tend to them all as quickly as we'd like. This is especially
389 true for completely new plugins or new features.
390
391 If you haven't received any response at all for a while (say two weeks or so),
392 do feel free to ping developers by posting a quick follow-up comment on the
393 issue or merge request.
394
395 If you do not get a response, this is usually not a sign of people *ignoring*
396 the issue, but usually just means that it's fallen through the cracks or
397 people have been busy with other things.
398
399 ### Updating Your Merge Request and Addressing Review Comments
400
401 When someone reviews your changes, they may leave review comments for
402 particular sections of code or in general. These will usually each start
403 a new "Discussion" which is basically a thread for each comment.
404
405 When you believe that you have addressed the issue raised in a discussion,
406 either by updating the code or answering the questions raised, you should
407 "Resolve the Discussion" using the button.
408
409 This way it is easy to see for maintainers and for yourself what's left to do
410 and if there are any open questions/issues.
411
412 Whenever you have made changes to your patches locally you can just
413 `git push -f your-personal-gitlab-fork your-branch` to your personal fork,
414 and GitLab will pick up the changes automatically. You do _not_ need to submit
415 a new Merge Request whenever you make changes to an already-submitted patchset,
416 and in fact you shouldn't do that because it means all the previous discussion
417 context is lost and it's also not easy for reviewers to see what changed.
418 Just update your existing branch.
419
420 # Workflows for GStreamer developers
421
422 ## Backporting to a stable branch
423
424 Before backporting any changes to a stable branch, they should first be
425 applied to the `master` branch, and should obviously not have caused any known
426 outstanding regressions. The only exception here are changes that do not apply
427 to the `master` branch anymore.
428
429 Existing merge request against the `master` branch, including merged ones,
430 that should be considered for backporting in the future should be labeled with
431 the `Needs backport` label unless there is any specific urgency to get it
432 backported. All merge requests with the [`Needs backport`][needs-backport]
433 label will be regularly considered for backporting by GStreamer developers.
434
435 ### Creating a merge request for backports
436
437 When creating a merge request for backporting changes, include one or more
438 changes in the merge request and ideally all from the [`Needs
439 backport`][needs-backport] list after reviewing them and potentially fixing them
440 to work cleanly with the stable branch.
441
442 If there are specific commits or areas of commits where further feedback is
443 needed, please create a task list in the description of the merge request and
444 @ the committer or whoever has knowledge about this commit.
445
446 Add another task to the task list in the merge request's description for the
447 module's maintainer(s) to confirm the merge and @ one or more maintainers.
448
449 Only once the CI succeeded for the merge request and all tasks are solved,
450 especially the confirmation from the maintainer(s), the merge request can be
451 merged.
452
453 [needs-backport]: https://gitlab.freedesktop.org/groups/gstreamer/-/merge_requests?state=merged&label_name[]=Needs%20backport