rtpmux: Rename have_base to have_ts_base
[platform/upstream/gst-plugins-good.git] / gst / rtpmanager / gstrtpmux.c
1 /* RTP muxer element for GStreamer
2  *
3  * gstrtpmux.c:
4  *
5  * Copyright (C) <2007> Nokia Corporation.
6  *   Contact: Zeeshan Ali <zeeshan.ali@nokia.com>
7  * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
8  *               2000,2005 Wim Taymans <wim@fluendo.com>
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Library General Public
12  * License as published by the Free Software Foundation; either
13  * version 2 of the License, or (at your option) any later version.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * Library General Public License for more details.
19  *
20  * You should have received a copy of the GNU Library General Public
21  * License along with this library; if not, write to the
22  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23  * Boston, MA 02111-1307, USA.
24  */
25
26 /**
27  * SECTION:element-rtpmux
28  * @short_description: Muxer that takes one or several RTP streams
29  * and muxes them to a single rtp stream.
30  *
31  * <refsect2>
32  * </refsect2>
33  */
34
35 #ifdef HAVE_CONFIG_H
36 #include "config.h"
37 #endif
38
39 #include <gst/gst.h>
40 #include <gst/rtp/gstrtpbuffer.h>
41 #include <gstrtpmux.h>
42 #include <string.h>
43
44 GST_DEBUG_CATEGORY_STATIC (gst_rtp_mux_debug);
45 #define GST_CAT_DEFAULT gst_rtp_mux_debug
46
47 /* elementfactory information */
48 static const GstElementDetails gst_rtp_mux_details =
49 GST_ELEMENT_DETAILS ("RTP muxer",
50     "Codec/Muxer",
51     "multiplex N rtp streams into one",
52     "Zeeshan Ali <first.last@nokia.com>");
53
54 enum
55 {
56   ARG_0,
57   PROP_TIMESTAMP_OFFSET,
58   PROP_SEQNUM_OFFSET,
59   PROP_SEQNUM,
60   PROP_SSRC
61 };
62
63 #define DEFAULT_TIMESTAMP_OFFSET -1
64 #define DEFAULT_SEQNUM_OFFSET    -1
65 #define DEFAULT_SSRC             -1
66
67 typedef struct {
68   gboolean have_ts_base;
69   guint clock_base;
70 } GstRTPMuxPadPrivate;
71
72 static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
73     GST_PAD_SRC,
74     GST_PAD_ALWAYS,
75     GST_STATIC_CAPS ("application/x-rtp")
76     );
77
78 static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink_%d",
79     GST_PAD_SINK,
80     GST_PAD_REQUEST,
81     GST_STATIC_CAPS ("application/x-rtp")
82     );
83
84 static void gst_rtp_mux_base_init (gpointer g_class);
85 static void gst_rtp_mux_class_init (GstRTPMuxClass * klass);
86 static void gst_rtp_mux_init (GstRTPMux * rtp_mux);
87
88 static void gst_rtp_mux_finalize (GObject * object);
89
90 static GstPad *gst_rtp_mux_request_new_pad (GstElement * element,
91     GstPadTemplate * templ, const gchar * name);
92 static void gst_rtp_mux_release_pad (GstElement * element, GstPad *pad);
93 static GstFlowReturn gst_rtp_mux_chain (GstPad * pad,
94     GstBuffer * buffer);
95 static gboolean gst_rtp_mux_setcaps (GstPad *pad, GstCaps *caps);
96 static GstCaps * gst_rtp_mux_getcaps (GstPad *pad);
97
98 static GstStateChangeReturn gst_rtp_mux_change_state (GstElement *
99     element, GstStateChange transition);
100
101 static void gst_rtp_mux_set_property (GObject * object, guint prop_id,
102     const GValue * value, GParamSpec * pspec);
103 static void gst_rtp_mux_get_property (GObject * object, guint prop_id,
104     GValue * value, GParamSpec * pspec);
105
106 static gboolean gst_rtp_mux_src_event (GstPad * pad, GstEvent * event);
107
108 static GstElementClass *parent_class = NULL;
109
110 GType
111 gst_rtp_mux_get_type (void)
112 {
113   static GType rtp_mux_type = 0;
114
115   if (!rtp_mux_type) {
116     static const GTypeInfo rtp_mux_info = {
117       sizeof (GstRTPMuxClass),
118       gst_rtp_mux_base_init,
119       NULL,
120       (GClassInitFunc) gst_rtp_mux_class_init,
121       NULL,
122       NULL,
123       sizeof (GstRTPMux),
124       0,
125       (GInstanceInitFunc) gst_rtp_mux_init,
126     };
127
128     rtp_mux_type =
129         g_type_register_static (GST_TYPE_ELEMENT, "GstRTPMux",
130         &rtp_mux_info, 0);
131   }
132   return rtp_mux_type;
133 }
134
135 static void
136 gst_rtp_mux_base_init (gpointer g_class)
137 {
138   GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
139
140   gst_element_class_add_pad_template (element_class,
141       gst_static_pad_template_get (&src_factory));
142   gst_element_class_add_pad_template (element_class,
143       gst_static_pad_template_get (&sink_factory));
144
145   gst_element_class_set_details (element_class, &gst_rtp_mux_details);
146 }
147
148 static void
149 gst_rtp_mux_class_init (GstRTPMuxClass * klass)
150 {
151   GObjectClass *gobject_class;
152   GstElementClass *gstelement_class;
153
154   gobject_class = (GObjectClass *) klass;
155   gstelement_class = (GstElementClass *) klass;
156
157   parent_class = g_type_class_peek_parent (klass);
158
159   gobject_class->finalize = gst_rtp_mux_finalize;
160   gobject_class->get_property = gst_rtp_mux_get_property;
161   gobject_class->set_property = gst_rtp_mux_set_property;
162
163   g_object_class_install_property (G_OBJECT_CLASS (klass),
164       PROP_TIMESTAMP_OFFSET, g_param_spec_int ("timestamp-offset",
165           "Timestamp Offset",
166           "Offset to add to all outgoing timestamps (-1 = random)", -1,
167           G_MAXINT, DEFAULT_TIMESTAMP_OFFSET, G_PARAM_READWRITE));
168   g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_SEQNUM_OFFSET,
169       g_param_spec_int ("seqnum-offset", "Sequence number Offset",
170           "Offset to add to all outgoing seqnum (-1 = random)", -1, G_MAXINT,
171           DEFAULT_SEQNUM_OFFSET, G_PARAM_READWRITE));
172   g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_SEQNUM,
173       g_param_spec_uint ("seqnum", "Sequence number",
174           "The RTP sequence number of the last processed packet",
175           0, G_MAXUINT, 0, G_PARAM_READABLE));
176   g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_SSRC,
177       g_param_spec_uint ("ssrc", "SSRC",
178           "The SSRC of the packets (-1 == random)",
179           0, G_MAXUINT, DEFAULT_SSRC, G_PARAM_READWRITE));
180
181   gstelement_class->request_new_pad = gst_rtp_mux_request_new_pad;
182   gstelement_class->release_pad = gst_rtp_mux_release_pad;
183   gstelement_class->change_state = gst_rtp_mux_change_state;
184
185   klass->chain_func = gst_rtp_mux_chain;
186 }
187
188 static gboolean gst_rtp_mux_src_event (GstPad * pad,
189     GstEvent * event)
190 {
191   GstElement *rtp_mux;
192   GstIterator *iter;
193   GstPad *sinkpad;
194   gboolean result = FALSE;
195   gboolean done = FALSE;
196
197   rtp_mux = gst_pad_get_parent_element (pad);
198   g_return_val_if_fail (rtp_mux != NULL, FALSE);
199
200   iter = gst_element_iterate_sink_pads (rtp_mux);
201
202   while (!done) {
203     switch (gst_iterator_next (iter, (gpointer) &sinkpad)) {
204       case GST_ITERATOR_OK:
205         gst_event_ref (event);
206         result |= gst_pad_push_event (sinkpad, event);
207         gst_object_unref (sinkpad);
208         break;
209       case GST_ITERATOR_RESYNC:
210         gst_iterator_resync (iter);
211         result = FALSE;
212         break;
213       case GST_ITERATOR_ERROR:
214         GST_WARNING_OBJECT (rtp_mux, "Error iterating sinkpads");
215       case GST_ITERATOR_DONE:
216         done = TRUE;
217         break;
218     }
219   }
220   gst_iterator_free (iter);
221   gst_object_unref (rtp_mux);
222   gst_event_unref (event);
223
224   return result;
225 }
226
227 static void
228 gst_rtp_mux_init (GstRTPMux * rtp_mux)
229 {
230   GstElementClass *klass = GST_ELEMENT_GET_CLASS (rtp_mux);
231
232   rtp_mux->srcpad =
233       gst_pad_new_from_template (gst_element_class_get_pad_template (klass,
234           "src"), "src");
235   gst_pad_set_event_function (rtp_mux->srcpad, gst_rtp_mux_src_event);
236   gst_element_add_pad (GST_ELEMENT (rtp_mux), rtp_mux->srcpad);
237
238   rtp_mux->ssrc = DEFAULT_SSRC;
239   rtp_mux->ts_offset = DEFAULT_TIMESTAMP_OFFSET;
240   rtp_mux->seqnum_offset = DEFAULT_SEQNUM_OFFSET;
241 }
242
243 static void
244 gst_rtp_mux_finalize (GObject * object)
245 {
246   GstRTPMux *rtp_mux;
247
248   rtp_mux = GST_RTP_MUX (object);
249
250   G_OBJECT_CLASS (parent_class)->finalize (object);
251 }
252
253 static GstPad *
254 gst_rtp_mux_create_sinkpad (GstRTPMux * rtp_mux, GstPadTemplate * templ)
255 {
256   GstPad *newpad = NULL;
257   GstPadTemplate * class_templ;
258
259   class_templ = gst_element_class_get_pad_template (
260           GST_ELEMENT_GET_CLASS (rtp_mux), "sink_%d");
261
262   if (templ == class_templ) {
263     gchar *name;
264
265     /* create new pad with the name */
266     name = g_strdup_printf ("sink_%02d", rtp_mux->numpads);
267     newpad = gst_pad_new_from_template (templ, name);
268     g_free (name);
269
270     rtp_mux->numpads++;
271   } else {
272     GST_WARNING_OBJECT (rtp_mux, "this is not our template!\n");
273   }
274
275   return newpad;
276 }
277
278 static void
279 gst_rtp_mux_setup_sinkpad (GstRTPMux * rtp_mux, GstPad * sinkpad)
280 {
281   GstRTPMuxClass *klass;
282   GstRTPMuxPadPrivate *padpriv = g_slice_new0 (GstRTPMuxPadPrivate);
283
284   klass = GST_RTP_MUX_GET_CLASS (rtp_mux);
285
286   /* setup some pad functions */
287   gst_pad_set_setcaps_function (sinkpad, gst_rtp_mux_setcaps);
288   gst_pad_set_getcaps_function (sinkpad, gst_rtp_mux_getcaps);
289   if (klass->chain_func)
290     gst_pad_set_chain_function (sinkpad, klass->chain_func);
291   if (klass->sink_event_func)
292     gst_pad_set_event_function (sinkpad, klass->sink_event_func);
293
294   /* This could break with gstreamer 0.10.9 */
295   gst_pad_set_active (sinkpad, TRUE);
296
297   gst_pad_set_element_private (sinkpad, padpriv);
298
299   /* dd the pad to the element */
300   gst_element_add_pad (GST_ELEMENT (rtp_mux), sinkpad);
301 }
302
303 static GstPad *
304 gst_rtp_mux_request_new_pad (GstElement * element,
305     GstPadTemplate * templ, const gchar * req_name)
306 {
307   GstRTPMux *rtp_mux;
308   GstPad *newpad;
309
310   g_return_val_if_fail (templ != NULL, NULL);
311   g_return_val_if_fail (GST_IS_RTP_MUX (element), NULL);
312
313   rtp_mux = GST_RTP_MUX (element);
314
315   if (templ->direction != GST_PAD_SINK) {
316     GST_WARNING_OBJECT (rtp_mux, "request pad that is not a SINK pad");
317     return NULL;
318   }
319
320   newpad = gst_rtp_mux_create_sinkpad (rtp_mux, templ);
321   if (newpad)
322     gst_rtp_mux_setup_sinkpad (rtp_mux, newpad);
323   else
324     GST_WARNING_OBJECT (rtp_mux, "failed to create request pad");
325
326   return newpad;
327 }
328
329 static void
330 gst_rtp_mux_release_pad (GstElement * element, GstPad *pad)
331 {
332   GstRTPMuxPadPrivate *padpriv = gst_pad_get_element_private (pad);
333
334   if (padpriv)
335     g_slice_free (GstRTPMuxPadPrivate, padpriv);
336   gst_pad_set_element_private (pad, NULL);
337
338   gst_element_remove_pad (element, pad);
339 }
340
341 /* Put our own clock-base on the buffer */
342 static void
343 gst_rtp_mux_readjust_rtp_timestamp (GstRTPMux * rtp_mux, GstPad * pad,
344     GstBuffer * buffer)
345 {
346   guint32 ts;
347   guint32 sink_ts_base = 0;
348   GstRTPMuxPadPrivate *padpriv = gst_pad_get_element_private (pad);
349
350   if (padpriv->have_ts_base)
351     sink_ts_base = padpriv->clock_base;
352
353   ts = gst_rtp_buffer_get_timestamp (buffer) - sink_ts_base + rtp_mux->ts_base;
354   GST_LOG_OBJECT (rtp_mux, "Re-adjusting RTP ts %u to %u",
355       gst_rtp_buffer_get_timestamp (buffer), ts);
356   gst_rtp_buffer_set_timestamp (buffer, ts);
357 }
358
359 static GstFlowReturn
360 gst_rtp_mux_chain (GstPad * pad, GstBuffer * buffer)
361 {
362   GstRTPMux *rtp_mux;
363   GstStructure * structure;
364   GstFlowReturn ret;
365
366   rtp_mux = GST_RTP_MUX (gst_pad_get_parent (pad));
367
368   if (!gst_rtp_buffer_validate (buffer)) {
369     GST_ERROR_OBJECT (rtp_mux, "Invalid RTP buffer");
370     gst_object_unref (rtp_mux);
371     return GST_FLOW_ERROR;
372   }
373
374   buffer = gst_buffer_make_writable(buffer);
375
376   GST_OBJECT_LOCK (rtp_mux);
377   rtp_mux->seqnum++;
378   gst_rtp_buffer_set_seq (buffer, rtp_mux->seqnum);
379   GST_OBJECT_UNLOCK (rtp_mux);
380   GST_BUFFER_CAPS (buffer) = gst_caps_make_writable(GST_BUFFER_CAPS (buffer));
381   structure = gst_caps_get_structure (GST_BUFFER_CAPS (buffer), 0U);
382   gst_structure_set (structure, "seqnum-base", G_TYPE_UINT, rtp_mux->seqnum_base, NULL);
383   gst_rtp_buffer_set_ssrc (buffer, rtp_mux->current_ssrc);
384   gst_rtp_mux_readjust_rtp_timestamp (rtp_mux, pad, buffer);
385   GST_LOG_OBJECT (rtp_mux, "Pushing packet size %d, seq=%d, ts=%u",
386       GST_BUFFER_SIZE (buffer), rtp_mux->seqnum,
387       gst_rtp_buffer_get_timestamp (buffer));
388
389   gst_buffer_set_caps (buffer, GST_PAD_CAPS (rtp_mux->srcpad));
390
391   ret = gst_pad_push (rtp_mux->srcpad, buffer);
392
393   gst_object_unref (rtp_mux);
394   return ret;
395 }
396
397 static gboolean
398 gst_rtp_mux_setcaps (GstPad *pad, GstCaps *caps)
399 {
400   GstRTPMux *rtp_mux;
401   GstStructure *structure;
402   gboolean ret = TRUE;
403   GstRTPMuxPadPrivate *padpriv = gst_pad_get_element_private (pad);
404
405   rtp_mux = GST_RTP_MUX (gst_pad_get_parent (pad));
406
407   structure = gst_caps_get_structure (caps, 0);
408
409   if (!ret)
410     goto out;
411
412   if (gst_structure_get_uint (structure, "clock-base", &padpriv->clock_base)) {
413     padpriv->have_ts_base = TRUE;
414   }
415
416   caps = gst_caps_copy (caps);
417
418   gst_caps_set_simple (caps,
419       "clock-base", G_TYPE_UINT, rtp_mux->ts_base,
420       "seqnum-base", G_TYPE_UINT, rtp_mux->seqnum_base,
421       NULL);
422
423   GST_DEBUG_OBJECT (rtp_mux,
424       "setting caps %" GST_PTR_FORMAT " on src pad..", caps);
425   ret = gst_pad_set_caps (rtp_mux->srcpad, caps);
426   gst_caps_unref (caps);
427
428  out:
429   gst_object_unref (rtp_mux);
430
431   return ret;
432 }
433
434 static void
435 clear_caps (GstCaps *caps)
436 {
437   gint i, j;
438
439   /* Lets only match on the clock-rate */
440   for (i = 0; i < gst_caps_get_size (caps); i++) {
441     GstStructure *s = gst_caps_get_structure (caps, i);
442
443     for (j = 0; j < gst_structure_n_fields (s); j++) {
444       const gchar *name = gst_structure_nth_field_name (s, j);
445
446       if (strcmp (name, "clock-rate")) {
447         gst_structure_remove_field (s, name);
448         j--;
449       }
450     }
451   }
452 }
453
454 static gboolean
455 same_clock_rate_fold (gpointer item, GValue *ret, gpointer user_data)
456 {
457   GstPad *mypad = user_data;
458   GstPad *pad = item;
459   GstCaps *peercaps;
460   GstCaps *othercaps;
461   const GstCaps *accumcaps;
462   GstCaps *intersect;
463
464   if (pad == mypad)
465     return TRUE;
466
467   peercaps = gst_pad_peer_get_caps (pad);
468   if (!peercaps)
469     return TRUE;
470
471   othercaps = gst_caps_intersect (peercaps,
472       gst_pad_get_pad_template_caps (pad));
473   gst_caps_unref (peercaps);
474
475   accumcaps = gst_value_get_caps (ret);
476
477   clear_caps (othercaps);
478
479   intersect = gst_caps_intersect (accumcaps, othercaps);
480
481   g_value_take_boxed (ret, intersect);
482
483   gst_caps_unref (othercaps);
484
485   return !gst_caps_is_empty (intersect);
486 }
487
488 static GstCaps *
489 gst_rtp_mux_getcaps (GstPad *pad)
490 {
491   GstRTPMux *mux = GST_RTP_MUX (gst_pad_get_parent (pad));
492   GstCaps *caps = NULL;
493   GstIterator *iter = NULL;
494   GValue v = {0};
495   GstIteratorResult res;
496   GstCaps *peercaps = gst_pad_peer_get_caps (mux->srcpad);
497   GstCaps *othercaps =  NULL;
498
499   if (peercaps) {
500     othercaps = gst_caps_intersect (peercaps,
501         gst_pad_get_pad_template_caps (pad));
502     gst_caps_unref (peercaps);
503   }
504   else {
505     othercaps = gst_caps_copy (gst_pad_get_pad_template_caps (mux->srcpad));
506   }
507
508   clear_caps (othercaps);
509
510   g_value_init (&v, GST_TYPE_CAPS);
511
512   iter = gst_element_iterate_sink_pads (GST_ELEMENT (mux));
513   do {
514     gst_value_set_caps (&v, othercaps);
515     res = gst_iterator_fold (iter, same_clock_rate_fold, &v, pad);
516   } while (res == GST_ITERATOR_RESYNC);
517   gst_iterator_free (iter);
518
519   caps = (GstCaps*) gst_value_get_caps (&v);
520
521   if (res == GST_ITERATOR_ERROR) {
522     gst_caps_unref (caps);
523     caps = gst_caps_new_empty ();
524   }
525
526   if (othercaps)
527     gst_caps_unref (othercaps);
528   gst_object_unref (mux);
529
530   return caps;
531 }
532
533
534 static void
535 gst_rtp_mux_get_property (GObject * object,
536     guint prop_id, GValue * value, GParamSpec * pspec)
537 {
538   GstRTPMux *rtp_mux;
539
540   rtp_mux = GST_RTP_MUX (object);
541
542   switch (prop_id) {
543     case PROP_TIMESTAMP_OFFSET:
544       g_value_set_int (value, rtp_mux->ts_offset);
545       break;
546     case PROP_SEQNUM_OFFSET:
547       g_value_set_int (value, rtp_mux->seqnum_offset);
548       break;
549     case PROP_SEQNUM:
550       GST_OBJECT_LOCK (rtp_mux);
551       g_value_set_uint (value, rtp_mux->seqnum);
552       GST_OBJECT_UNLOCK (rtp_mux);
553       break;
554     case PROP_SSRC:
555       g_value_set_uint (value, rtp_mux->ssrc);
556       break;
557     default:
558       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
559       break;
560   }
561 }
562
563 static void
564 gst_rtp_mux_set_property (GObject * object,
565     guint prop_id, const GValue * value, GParamSpec * pspec)
566 {
567   GstRTPMux *rtp_mux;
568
569   rtp_mux = GST_RTP_MUX (object);
570
571   switch (prop_id) {
572     case PROP_TIMESTAMP_OFFSET:
573       rtp_mux->ts_offset = g_value_get_int (value);
574       break;
575     case PROP_SEQNUM_OFFSET:
576       rtp_mux->seqnum_offset = g_value_get_int (value);
577       break;
578     case PROP_SSRC:
579       rtp_mux->ssrc = g_value_get_uint (value);
580       break;
581     default:
582       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
583       break;
584   }
585 }
586
587 static void
588 gst_rtp_mux_ready_to_paused (GstRTPMux * rtp_mux)
589 {
590   GST_OBJECT_LOCK (rtp_mux);
591
592   if (rtp_mux->ssrc == -1)
593     rtp_mux->current_ssrc = g_random_int ();
594   else
595     rtp_mux->current_ssrc = rtp_mux->ssrc;
596
597   if (rtp_mux->seqnum_offset == -1)
598     rtp_mux->seqnum_base = g_random_int_range (0, G_MAXUINT16);
599   else
600     rtp_mux->seqnum_base = rtp_mux->seqnum_offset;
601   rtp_mux->seqnum = rtp_mux->seqnum_base;
602
603   if (rtp_mux->ts_offset == -1)
604     rtp_mux->ts_base = g_random_int ();
605   else
606     rtp_mux->ts_base = rtp_mux->ts_offset;
607     GST_DEBUG_OBJECT (rtp_mux, "set clock-base to %u", rtp_mux->ts_base);
608
609   GST_OBJECT_UNLOCK (rtp_mux);
610 }
611
612 static GstStateChangeReturn
613 gst_rtp_mux_change_state (GstElement * element, GstStateChange transition)
614 {
615   GstRTPMux *rtp_mux;
616
617   rtp_mux = GST_RTP_MUX (element);
618
619   switch (transition) {
620     case GST_STATE_CHANGE_NULL_TO_READY:
621       break;
622     case GST_STATE_CHANGE_READY_TO_PAUSED:
623       gst_rtp_mux_ready_to_paused (rtp_mux);
624       break;
625     case GST_STATE_CHANGE_PAUSED_TO_READY:
626       break;
627     default:
628       break;
629   }
630
631   return GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
632 }
633
634 gboolean
635 gst_rtp_mux_plugin_init (GstPlugin * plugin)
636 {
637   GST_DEBUG_CATEGORY_INIT (gst_rtp_mux_debug, "rtpmux", 0,
638       "rtp muxer");
639
640   return gst_element_register (plugin, "rtpmux", GST_RANK_NONE,
641       GST_TYPE_RTP_MUX);
642 }
643