en50221_stdcam.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. en50221 encoder An implementation for libdvb
  3. an implementation for the en50221 transport layer
  4. Copyright (C) 2006 Andrew de Quincey (adq_dvb@lidskialf.net)
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU Lesser General Public License as
  7. published by the Free Software Foundation; either version 2.1 of
  8. the License, or (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with this library; if not, write to the Free Software
  15. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. */
  17. #include <stdio.h>
  18. #include <unistd.h>
  19. #include <limits.h>
  20. #include <string.h>
  21. #include <errno.h>
  22. #include <libdvbapi/dvbca.h>
  23. #include "en50221_stdcam.h"
  24. struct en50221_stdcam *en50221_stdcam_create(int adapter, int slotnum,
  25. struct en50221_transport_layer *tl,
  26. struct en50221_session_layer *sl)
  27. {
  28. struct en50221_stdcam *result = NULL;
  29. int cafd = dvbca_open(adapter, 0);
  30. if (cafd == -1)
  31. return NULL;
  32. int ca_type = dvbca_get_interface_type(cafd, slotnum);
  33. switch(ca_type) {
  34. case DVBCA_INTERFACE_LINK:
  35. result = en50221_stdcam_llci_create(cafd, slotnum, tl, sl);
  36. break;
  37. case DVBCA_INTERFACE_HLCI:
  38. result = en50221_stdcam_hlci_create(cafd, slotnum);
  39. break;
  40. }
  41. if (result == NULL)
  42. close(cafd);
  43. return result;
  44. }